92 } |
105 } |
93 |
106 |
94 /*! |
107 /*! |
95 Loads docml files. |
108 Loads docml files. |
96 */ |
109 */ |
97 void FmRadioHsWidget::load(QString DOCML) |
110 void FmRadioHsWidget::load(const QString docml) |
98 { |
111 { |
99 bool loaded = false; |
112 bool loaded = false; |
100 |
113 |
101 HbDocumentLoader *documentLoader = new HbDocumentLoader(); |
114 HbDocumentLoader *documentLoader = new HbDocumentLoader(); |
102 documentLoader->reset(); |
115 documentLoader->reset(); |
103 documentLoader->load(DOCML, &loaded); |
116 documentLoader->load(docml, &loaded); |
104 |
117 |
105 if (loaded) { |
118 if (loaded) { |
106 HbWidget *widget = qobject_cast<HbWidget*> (documentLoader->findWidget(QString(KDocmlObjectNameMainLayout))); |
119 HbWidget *widget = qobject_cast<HbWidget*> (documentLoader->findWidget( |
|
120 KDocmlObjectNameMainLayout)); |
|
121 |
|
122 HbFrameItem *frameItem = NULL; |
|
123 |
107 if (widget) { |
124 if (widget) { |
108 //HbWidget *view = qobject_cast<HbWidget*> (widget); |
125 //HbWidget *view = qobject_cast<HbWidget*> (widget); |
109 QGraphicsLinearLayout *mWidgetLayout = new QGraphicsLinearLayout(Qt::Vertical, this); |
126 QGraphicsLinearLayout *mWidgetLayout = new QGraphicsLinearLayout(Qt::Vertical, this); |
|
127 |
|
128 HbFrameDrawer *drawer = new HbFrameDrawer("qtg_fr_hswidget_normal", |
|
129 HbFrameDrawer::NinePieces); |
|
130 frameItem = new HbFrameItem(drawer, widget); |
|
131 frameItem->setPreferredSize(widget->preferredSize()); |
|
132 |
110 mWidgetLayout->addItem(widget); |
133 mWidgetLayout->addItem(widget); |
111 setLayout(mWidgetLayout); |
134 setLayout(mWidgetLayout); |
112 } |
135 } |
113 |
136 |
114 mRadioPushButton = qobject_cast<HbPushButton *> (documentLoader->findObject(QString(KDocmlObjectNameRadioIconPushButton))); |
137 mRadioPushButton = qobject_cast<HbPushButton*> (documentLoader->findWidget( |
|
138 KDocmlObjectNameRadioIconPushButton)); |
115 if (mRadioPushButton) { |
139 if (mRadioPushButton) { |
116 // Invalid icon for the mRadioPushButton to make it look not like a button. |
140 if (frameItem) { |
117 mRadioPushButton->setBackground(HbIcon(" ")); |
141 frameItem->stackBefore(mRadioPushButton); |
118 mRadioPushButton->setIcon(HbIcon("qtg_large_radio")); |
142 } |
|
143 mRadioPushButton->setBackground(HbIcon("qtg_large_radio")); |
|
144 mRadioPushButton->icon().setSize(mRadioPushButton->preferredSize()); |
119 QObject::connect(mRadioPushButton, SIGNAL(clicked()), this, SLOT(radioToForeground())); |
145 QObject::connect(mRadioPushButton, SIGNAL(clicked()), this, SLOT(radioToForeground())); |
120 } |
146 } |
121 |
147 |
122 mPreviousPushButton = qobject_cast<HbPushButton *> (documentLoader->findObject(QString( |
148 mVerticalSeparatorLabel = qobject_cast<HbLabel*> (documentLoader->findWidget( |
123 KDocmlObjectNamePreviousPushButton))); |
149 KDocmlObjectNameVerticalSeparatorLabel)); |
|
150 if (mVerticalSeparatorLabel) { |
|
151 mVerticalSeparatorLabel->setIcon(HbIcon("qtg_graf_divider_v_thin")); |
|
152 } |
|
153 |
|
154 HbWidget *controlAreaLayoutWidget = qobject_cast<HbWidget*> (documentLoader->findWidget( |
|
155 KDocmlObjectNameControlAreaLayout)); |
|
156 if (controlAreaLayoutWidget) { |
|
157 } |
|
158 |
|
159 mPreviousPushButton = qobject_cast<HbPushButton *> (documentLoader->findWidget( |
|
160 KDocmlObjectNamePreviousPushButton)); |
124 if (mPreviousPushButton) { |
161 if (mPreviousPushButton) { |
125 mPreviousPushButton->setIcon(HbIcon("qtg_mono_previous")); |
162 changeControlButtonFrameBackground(false, Left, mPreviousPushButton); |
126 QObject::connect(mPreviousPushButton, SIGNAL(clicked()), this, SLOT(previousChannel())); |
163 /* |
127 } |
164 HbFrameDrawer *previousButtonFrameDrawer = new HbFrameDrawer("qtg_fr_hsbutton_disabled", |
128 |
165 HbFrameDrawer::ThreePiecesHorizontal); |
129 mPlayPushButton = qobject_cast<HbPushButton *> (documentLoader->findObject(QString( |
166 previousButtonFrameDrawer->setFileNameSuffixList(QStringList() << "_l" << "_c" << "_cr"); |
130 KDocmlObjectNamePlayPushButton))); |
167 mPreviousPushButton->setFrameBackground(previousButtonFrameDrawer); |
|
168 */ QObject::connect(mPreviousPushButton, SIGNAL(clicked()), this, SLOT(previousChannel())); |
|
169 } |
|
170 |
|
171 mPlayPushButton = qobject_cast<HbPushButton *> (documentLoader->findWidget( |
|
172 KDocmlObjectNamePlayPushButton)); |
131 if (mPlayPushButton) { |
173 if (mPlayPushButton) { |
132 QObject::connect(mPlayPushButton, SIGNAL(clicked()), this, SLOT(radioToBackground())); |
174 changeControlButtonFrameBackground(false, Center, mPlayPushButton); |
133 } |
175 /* HbFrameDrawer *playButtonFrameDrawer = new HbFrameDrawer("qtg_fr_hsbutton_disabled", |
134 |
176 HbFrameDrawer::ThreePiecesHorizontal); |
135 mNextPushButton = qobject_cast<HbPushButton *> (documentLoader->findObject(QString( |
177 playButtonFrameDrawer->setFileNameSuffixList(QStringList() << "_cl" << "_c" << "_cr"); |
136 KDocmlObjectNameNextPushButton))); |
178 mPlayPushButton->setFrameBackground(playButtonFrameDrawer); |
|
179 */ QObject::connect(mPlayPushButton, SIGNAL(clicked()), this, SLOT(radioToBackground())); |
|
180 } |
|
181 |
|
182 mNextPushButton = qobject_cast<HbPushButton *> (documentLoader->findWidget( |
|
183 KDocmlObjectNameNextPushButton)); |
137 if (mNextPushButton) { |
184 if (mNextPushButton) { |
138 mNextPushButton->setIcon(HbIcon("qtg_mono_next")); |
185 changeControlButtonFrameBackground(false, Right, mNextPushButton); |
139 QObject::connect(mNextPushButton, SIGNAL(clicked()), this, SLOT(nextChannel())); |
186 /* HbFrameDrawer *nextButtonFrameDrawer = new HbFrameDrawer("qtg_fr_hsbutton_disabled", |
140 } |
187 HbFrameDrawer::ThreePiecesHorizontal); |
|
188 nextButtonFrameDrawer->setFileNameSuffixList(QStringList() << "_cl" << "_c" << "_r"); |
|
189 mNextPushButton->setFrameBackground(nextButtonFrameDrawer); |
|
190 */ QObject::connect(mNextPushButton, SIGNAL(clicked()), this, SLOT(nextChannel())); |
|
191 } |
|
192 |
|
193 //bool b = QFile::exists(KCss); |
|
194 bool a = HbStyleLoader::registerFilePath(KCss); |
141 |
195 |
142 mInformationAreaTwoRowsLayout = qobject_cast<QGraphicsWidget *> ( |
196 mInformationAreaTwoRowsLayout = qobject_cast<QGraphicsWidget *> ( |
143 documentLoader->findObject(QString(KDocmlObjectNameTwoRowsLayout))); |
197 documentLoader->findObject(KDocmlObjectNameTwoRowsLayout)); |
144 if (mInformationAreaTwoRowsLayout) { |
198 if (mInformationAreaTwoRowsLayout) { |
|
199 /* |
|
200 QGraphicsLinearLayout *layout = new QGraphicsLinearLayout(Qt::Vertical, mInformationAreaTwoRowsLayout); |
|
201 mInformationFirstRowMarquee = new HbMarqueeItem(); |
|
202 HbStyle::setItemName(mInformationFirstRowMarquee, "marquee1"); |
|
203 mInformationFirstRowMarquee->setObjectName("marquee1"); |
|
204 mInformationFirstRowMarquee->setText( |
|
205 "Long text"); |
|
206 mInformationFirstRowMarquee->setLoopCount(-1); |
|
207 mInformationFirstRowMarquee->startAnimation(); |
|
208 HbFontSpec fs(HbFontSpec::Secondary); |
|
209 mInformationFirstRowMarquee->setFontSpec(fs); |
|
210 mInformationFirstRowMarquee->setTextColor(HbColorScheme::color("qtc_hs_list_item_title")); |
|
211 mInformationFirstRowMarquee->setPreferredSize(layout->preferredSize()); |
|
212 layout->addItem(mInformationFirstRowMarquee); |
|
213 |
|
214 mInformationSecondRowMarquee = new HbMarqueeItem(); |
|
215 mInformationSecondRowMarquee->setObjectName("marquee2"); |
|
216 mInformationSecondRowMarquee->setText( |
|
217 "Long text to test marquee, Long text to test marquee"); |
|
218 mInformationSecondRowMarquee->setLoopCount(-1); |
|
219 mInformationSecondRowMarquee->startAnimation(); |
|
220 mInformationSecondRowMarquee->setFontSpec(fs); |
|
221 mInformationSecondRowMarquee->setTextColor(HbColorScheme::color("qtc_hs_list_item_title")); |
|
222 mInformationSecondRowMarquee->setPreferredSize(layout->preferredSize()); |
|
223 layout->addItem(mInformationSecondRowMarquee); |
|
224 */ |
145 } |
225 } |
146 |
226 |
147 mInformationAreaOneRowLayout = qobject_cast<QGraphicsWidget *> (documentLoader->findObject( |
227 mInformationAreaOneRowLayout = qobject_cast<QGraphicsWidget *> (documentLoader->findObject( |
148 QString(KDocmlObjectNameOneRowLayout))); |
228 KDocmlObjectNameOneRowLayout)); |
149 if (mInformationAreaOneRowLayout) { |
229 if (mInformationAreaOneRowLayout) { |
|
230 /* |
|
231 QGraphicsLinearLayout *layout = new QGraphicsLinearLayout(Qt::Vertical, mInformationAreaOneRowLayout); |
|
232 mInformationLonelyRowMarquee = new HbMarqueeItem(); |
|
233 mInformationLonelyRowMarquee->setObjectName("marquee3"); |
|
234 HbStyle::setItemName(mInformationLonelyRowMarquee, "marquee3"); |
|
235 mInformationLonelyRowMarquee->setText( |
|
236 "Long text"); |
|
237 mInformationLonelyRowMarquee->setLoopCount(-1); |
|
238 mInformationLonelyRowMarquee->startAnimation(); |
|
239 HbFontSpec fs(HbFontSpec::Secondary); |
|
240 mInformationLonelyRowMarquee->setFontSpec(fs); |
|
241 mInformationLonelyRowMarquee->setTextColor(HbColorScheme::color("qtc_hs_list_item_title")); |
|
242 mInformationLonelyRowMarquee->setPreferredSize(layout->preferredSize()); |
|
243 layout->addItem(mInformationLonelyRowMarquee); |
|
244 */ |
150 } |
245 } |
151 |
246 |
152 mInformationAreaAnimationLayout = qobject_cast<QGraphicsWidget *> ( |
247 mInformationAreaAnimationLayout = qobject_cast<QGraphicsWidget *> ( |
153 documentLoader->findObject(QString(KDocmlObjectNameAnimationLayout))); |
248 documentLoader->findObject(QString(KDocmlObjectNameAnimationLayout))); |
154 if (mInformationAreaAnimationLayout) { |
249 if (mInformationAreaAnimationLayout) { |
155 } |
250 } |
156 |
251 |
157 mInformationFirstRowLabel = qobject_cast<HbLabel *> (documentLoader->findObject(QString( |
252 mInformationFirstRowLabel = qobject_cast<HbLabel *> (documentLoader->findWidget( |
158 KDocmlObjectNameFirstRowLabel))); |
253 KDocmlObjectNameFirstRowLabel)); |
159 if (mInformationFirstRowLabel) { |
254 if (mInformationFirstRowLabel) { |
160 mInformationFirstRowLabel->setTextColor("qtc_hs_list_item_title"); |
255 mInformationFirstRowLabel->setTextColor(HbColorScheme::color("qtc_hs_list_item_title")); |
161 } |
256 } |
162 |
257 |
163 mInformationSecondRowLabel = qobject_cast<HbLabel *> (documentLoader->findObject(QString( |
258 mInformationSecondRowLabel = qobject_cast<HbLabel *> (documentLoader->findWidget( |
164 KDocmlObjectNameSecondRowLabel))); |
259 KDocmlObjectNameSecondRowLabel)); |
165 if (mInformationSecondRowLabel) { |
260 if (mInformationSecondRowLabel) { |
166 mInformationSecondRowLabel->setTextColor("qtc_hs_list_item_content"); |
261 mInformationSecondRowLabel->setTextColor(HbColorScheme::color("qtc_hs_list_item_content")); |
167 } |
262 } |
168 |
263 |
169 mInformationLonelyRowLabel = qobject_cast<HbLabel *> (documentLoader->findObject(QString( |
264 mInformationLonelyRowLabel = qobject_cast<HbLabel *> (documentLoader->findWidget( |
170 KDocmlObjectNameLonelyRowLabel))); |
265 KDocmlObjectNameLonelyRowLabel)); |
171 if (mInformationLonelyRowLabel) { |
266 if (mInformationLonelyRowLabel) { |
172 mInformationLonelyRowLabel->setTextColor("qtc_hs_list_item_title"); |
267 mInformationLonelyRowLabel->setTextColor(HbColorScheme::color("qtc_hs_list_item_content")); |
173 } |
268 } |
174 |
269 |
175 mAnimatioIcon = qobject_cast<HbLabel *> (documentLoader->findObject( |
270 mAnimationIcon = qobject_cast<HbLabel *> (documentLoader->findWidget( |
176 QString())); |
271 KDocmlObjectNameAnimationIcon)); |
177 if (mAnimatioIcon) { |
272 if (mAnimationIcon) { |
178 mAnimatioIcon->setIcon(HbIcon("qtg_anim_loading_0")); |
273 // Use animation manager to define the frame-by-frame animation. |
|
274 HbIconAnimationManager *animationManager = HbIconAnimationManager::global(); |
|
275 |
|
276 // Create animation definition. |
|
277 HbIconAnimationDefinition animationDefinition; |
|
278 QList<HbIconAnimationDefinition::AnimationFrame> animationFrameList; |
|
279 |
|
280 HbIconAnimationDefinition::AnimationFrame animationFrame; |
|
281 QString animationFrameIconName; |
|
282 QString animationFrameIconNamePrefix = "qtg_anim_loading_"; |
|
283 for (int i = 1; i < 11; i++) { |
|
284 animationFrame.duration = 100; |
|
285 animationFrameIconName.clear(); |
|
286 animationFrameIconName.append(animationFrameIconNamePrefix); |
|
287 animationFrameIconName.append(animationFrameIconName.number(i)); |
|
288 animationFrame.iconName = animationFrameIconName; |
|
289 animationFrameList.append(animationFrame); |
|
290 } |
|
291 animationDefinition.setPlayMode(HbIconAnimationDefinition::Loop); |
|
292 animationDefinition.setFrameList(animationFrameList); |
|
293 animationManager->addDefinition("animation", animationDefinition); |
|
294 |
|
295 // Construct an icon using the animation definition. |
|
296 HbIcon icon("animation"); |
|
297 |
|
298 mAnimationIcon->setIcon(icon); |
179 } |
299 } |
180 |
300 |
181 } |
301 } |
182 delete documentLoader; |
302 delete documentLoader; |
183 } |
303 } |
219 Mute FM Radio audio. |
339 Mute FM Radio audio. |
220 */ |
340 */ |
221 void FmRadioHsWidget::mute() |
341 void FmRadioHsWidget::mute() |
222 { |
342 { |
223 mRadioServiceClient->doControlFmRadioAudio(FmRadioHsWidgetRadioServiceClient::Mute); |
343 mRadioServiceClient->doControlFmRadioAudio(FmRadioHsWidgetRadioServiceClient::Mute); |
224 handleRadioStateChange(QVariant(NotControllingAudio)); |
344 //handleRadioStateChange(QVariant(NotControllingAudio)); |
225 } |
345 } |
226 |
346 |
227 /*! |
347 /*! |
228 Unmute FM Radio audio. |
348 Unmute FM Radio audio. |
229 */ |
349 */ |
230 void FmRadioHsWidget::unMute() |
350 void FmRadioHsWidget::unMute() |
231 { |
351 { |
232 mRadioServiceClient->doControlFmRadioAudio(FmRadioHsWidgetRadioServiceClient::Unmute); |
352 mRadioServiceClient->doControlFmRadioAudio(FmRadioHsWidgetRadioServiceClient::Unmute); |
233 handleRadioStateChange(QVariant(ControllingAudio)); |
353 //handleRadioStateChange(QVariant(ControllingAudio)); |
234 } |
354 } |
235 |
355 |
236 /*! |
356 /*! |
237 Slot for previous button clicked. |
357 Slot for previous button clicked. |
238 */ |
358 */ |
239 void FmRadioHsWidget::previousChannel() |
359 void FmRadioHsWidget::previousChannel() |
240 { |
360 { |
241 mRadioServiceClient->doChangeFmRadioChannel(FmRadioHsWidgetRadioServiceClient::PreviousFavouriteChannel); |
361 mRadioServiceClient->doChangeFmRadioChannel(FmRadioHsWidgetRadioServiceClient::PreviousFavouriteChannel); |
242 clearRadioInformation(); |
|
243 } |
362 } |
244 |
363 |
245 /*! |
364 /*! |
246 Slot for next button clicked. |
365 Slot for next button clicked. |
247 */ |
366 */ |
248 void FmRadioHsWidget::nextChannel() |
367 void FmRadioHsWidget::nextChannel() |
249 { |
368 { |
250 mRadioServiceClient->doChangeFmRadioChannel(FmRadioHsWidgetRadioServiceClient::NextFavouriteChannel); |
369 mRadioServiceClient->doChangeFmRadioChannel(FmRadioHsWidgetRadioServiceClient::NextFavouriteChannel); |
251 clearRadioInformation(); |
|
252 } |
370 } |
253 |
371 |
254 /*! |
372 /*! |
255 Slot for radio button clicked. |
373 Slot for radio button clicked. |
256 */ |
374 */ |
257 void FmRadioHsWidget::radioToForeground() |
375 void FmRadioHsWidget::radioToForeground() |
258 { |
376 { |
259 if (mFmRadioState == NotRunning) { |
377 if (mFmRadioState == NotRunning) { |
260 mRadioServiceClient->startMonitoring(); |
378 handleRadioStateChange(QVariant(Starting)); |
261 handleRadioStateChange(QVariant(Running)); |
379 mRadioServiceClient->startMonitoring(FmRadioHsWidgetRadioServiceClient::ToForeground); |
262 } |
380 } |
263 mRadioServiceClient->doBringFmRadioToForeground(true); |
381 else { |
|
382 mRadioServiceClient->doChangeFmRadioVisibility( |
|
383 FmRadioHsWidgetRadioServiceClient::ToForeground); |
|
384 } |
264 } |
385 } |
265 |
386 |
266 /*! |
387 /*! |
267 Slot for radio button clicked. |
388 Slot for radio button clicked. |
268 */ |
389 */ |
269 void FmRadioHsWidget::radioToBackground() |
390 void FmRadioHsWidget::radioToBackground() |
270 { |
391 { |
271 if (mFmRadioState == NotRunning) { |
392 if (mFmRadioState == NotRunning) { |
272 mRadioServiceClient->startMonitoring(); |
393 handleRadioStateChange(QVariant(Starting)); |
273 handleRadioStateChange(QVariant(Running)); |
394 mRadioServiceClient->startMonitoring(FmRadioHsWidgetRadioServiceClient::ToBackground); |
274 } |
395 } |
275 } |
396 else if (mFmRadioState == Starting) { |
276 |
397 |
|
398 } |
|
399 else { |
|
400 mRadioServiceClient->doChangeFmRadioVisibility( |
|
401 FmRadioHsWidgetRadioServiceClient::ToBackground); |
|
402 } |
|
403 } |
|
404 |
|
405 /*! |
|
406 Opening of url to the browser. |
|
407 |
|
408 /param url Url to be opened. |
|
409 */ |
|
410 bool FmRadioHsWidget::openUrl(QUrl url) |
|
411 { |
|
412 return QDesktopServices::openUrl(url); |
|
413 } |
277 |
414 |
278 /*! |
415 /*! |
279 Handles changes in FM Radio information. |
416 Handles changes in FM Radio information. |
280 |
417 |
281 /param type Type of changed information. |
418 /param type Type of changed information. |
282 /param value Information content. |
419 /param value Information content. |
283 */ |
420 */ |
284 void FmRadioHsWidget::handleRadioInformationChange( |
421 void FmRadioHsWidget::handleRadioInformationChange( |
285 int notificationId, QVariant value) |
422 int notificationId, QVariant value) |
286 { |
423 { |
|
424 if (!value.isValid()) { |
|
425 return; |
|
426 } |
287 switch ( notificationId ) { |
427 switch ( notificationId ) { |
288 |
428 |
289 case RadioServiceNotification::FavoriteCount: |
429 case RadioServiceNotification::FavoriteCount: |
|
430 if (value.canConvert(QVariant::Int)) { |
|
431 int favoriteCount = value.toInt(); |
|
432 mIsFavoriteChannels = favoriteCount > 0 ? true : false; |
|
433 changeChannelButtonsEnabledState(mIsFavoriteChannels); |
|
434 } |
290 break; |
435 break; |
291 |
436 |
|
437 case RadioServiceNotification::RadioStatus: |
|
438 if (value.canConvert(QVariant::Int)) { |
|
439 int status = value.toInt(); |
|
440 switch (status) { |
|
441 case RadioStatus::Playing: |
|
442 handleRadioStateChange(QVariant(ControllingAudio)); |
|
443 break; |
|
444 case RadioStatus::Muted: |
|
445 handleRadioStateChange(QVariant(NotControllingAudio)); |
|
446 break; |
|
447 case RadioStatus::Seeking: |
|
448 handleRadioStateChange(QVariant(Seeking)); |
|
449 break; |
|
450 case RadioStatus::NoAntenna: |
|
451 handleRadioStateChange(QVariant(AntennaNotConnected)); |
|
452 break; |
|
453 default: |
|
454 break; |
|
455 } |
|
456 } |
|
457 break; |
|
458 |
292 case RadioServiceNotification::Frequency: |
459 case RadioServiceNotification::Frequency: |
293 { |
460 if (value.canConvert(QVariant::UInt)) { |
294 const uint frequency = value.toUInt(); |
461 const uint frequency = value.toUInt(); |
295 QString freqString; |
462 QString freqString; |
296 freqString.sprintf( "%.1f", qreal( frequency ) / KFrequencyMultiplier ); |
463 freqString.sprintf("%.1f", qreal(frequency) / KFrequencyMultiplier); |
297 if (updateRadioInformation( KRadioInformationFrequency, freqString )) { |
464 bool frequencyCleared = false; |
298 radioInformationChanged(); |
465 if (mRadioInformation.contains(KRadioInformationFrequency) |
|
466 && mRadioInformation[KRadioInformationFrequency].compare(freqString) != 0) { |
|
467 clearRadioInformation(); |
|
468 frequencyCleared = true; |
|
469 } |
|
470 bool frequencyUpdated = updateRadioInformation(KRadioInformationFrequency, freqString); |
|
471 if (frequencyCleared || frequencyUpdated) { |
|
472 radioInformationChanged(); |
|
473 } |
299 } |
474 } |
300 } |
|
301 break; |
475 break; |
302 |
476 |
303 case RadioServiceNotification::Name: |
477 case RadioServiceNotification::Name: |
304 if (updateRadioInformation( KRadioInformationStationName, value.toString() )) { |
478 if (value.canConvert(QVariant::String)) { |
305 radioInformationChanged(); |
479 if (updateRadioInformation(KRadioInformationStationName, value.toString())) { |
|
480 radioInformationChanged(); |
|
481 } |
306 } |
482 } |
307 break; |
483 break; |
|
484 |
|
485 case RadioServiceNotification::Genre: |
|
486 if (value.canConvert(QVariant::String)) { |
|
487 if (updateRadioInformation(KRadioInformationPty, value.toString())) { |
|
488 radioInformationChanged(); |
|
489 } |
|
490 } |
|
491 break; |
|
492 |
|
493 case RadioServiceNotification::RadioText: |
|
494 if (value.canConvert(QVariant::String)) { |
|
495 if (updateRadioInformation(KRadioInformationRt, value.toString())) { |
|
496 radioInformationChanged(); |
|
497 } |
|
498 } |
|
499 break; |
|
500 |
|
501 case RadioServiceNotification::HomePage: |
|
502 if (value.canConvert(QVariant::String)) { |
|
503 if (updateRadioInformation(KRadioInformationHomePage, value.toString())) { |
|
504 radioInformationChanged(); |
|
505 } |
|
506 } |
|
507 break; |
|
508 |
|
509 case RadioServiceNotification::Song: |
|
510 if (value.canConvert(QVariant::String)) { |
|
511 if (updateRadioInformation(KRadioInformationSong, value.toString())) { |
|
512 radioInformationChanged(); |
|
513 } |
|
514 } |
|
515 break; |
|
516 |
308 |
517 |
309 /* case FmRadioHsWidgetRadioServiceClient::InformationTypeCallSign: |
518 /* case FmRadioHsWidgetRadioServiceClient::InformationTypeCallSign: |
310 if (updateRadioInformation(KRadioInformationCallSign, informationText)) { |
519 if (updateRadioInformation(KRadioInformationCallSign, informationText)) { |
311 |
520 |
312 } |
521 } |
313 break; |
522 break; |
314 case FmRadioHsWidgetRadioServiceClient::InformationTypeFrequency: |
523 */ |
315 if (updateRadioInformation(KRadioInformationFrequency, |
|
316 informationText)) { |
|
317 |
|
318 } |
|
319 break; |
|
320 */ |
|
321 case RadioServiceNotification::RadioText: |
|
322 if (updateRadioInformation( KRadioInformationRt, value.toString() )) { |
|
323 radioInformationChanged(); |
|
324 } |
|
325 break; |
|
326 |
|
327 /* case FmRadioHsWidgetRadioServiceClient::InformationTypeDynamicPsName: |
524 /* case FmRadioHsWidgetRadioServiceClient::InformationTypeDynamicPsName: |
328 if (updateRadioInformation(KRadioInformationDynamicPsName, |
525 if (updateRadioInformation(KRadioInformationDynamicPsName, |
329 informationText)) { |
526 informationText)) { |
330 |
527 |
331 } |
528 } |
332 break; |
529 break; |
333 */ |
530 */ |
334 case RadioServiceNotification::Genre: |
531 |
335 if (updateRadioInformation( KRadioInformationPty, value.toString() )) { |
|
336 radioInformationChanged(); |
|
337 } |
|
338 break; |
|
339 |
|
340 case RadioServiceNotification::HomePage: |
|
341 break; |
|
342 |
|
343 case RadioServiceNotification::Song: |
|
344 break; |
|
345 |
|
346 default: |
532 default: |
347 break; |
533 break; |
348 } |
534 } |
349 } |
535 } |
350 |
536 |
461 // TODO: Some error occured because we do not have the state information. Handle this. |
654 // TODO: Some error occured because we do not have the state information. Handle this. |
462 mFmRadioState = Undefined; |
655 mFmRadioState = Undefined; |
463 break; |
656 break; |
464 case NotRunning: |
657 case NotRunning: |
465 mFmRadioState = NotRunning; |
658 mFmRadioState = NotRunning; |
466 //mRadioServiceClient->stopMonitoring(); |
659 mRadioServiceClient->stopMonitoring(); |
467 changeControlButtonState(ChannelsDisabledPlay); |
660 //changeControlButtonState(ChannelsDisabledPlay); |
468 mInformationFirstRowLabel->setPlainText(KFmRadioText); |
661 QObject::disconnect(mPlayPushButton, SIGNAL(clicked()), this, |
|
662 SLOT(unMute())); |
|
663 QObject::disconnect(mPlayPushButton, SIGNAL(clicked()), this, |
|
664 SLOT(mute())); |
|
665 QObject::connect(mPlayPushButton, SIGNAL(clicked()), this, |
|
666 SLOT(radioToBackground())); |
|
667 changePlayButtonState(PlayEnabled); |
|
668 mIsFavoriteChannels = false; |
|
669 changeChannelButtonsEnabledState(false); |
|
670 mInformationFirstRowLabel->setPlainText(""); |
469 mInformationSecondRowLabel->setPlainText(""); |
671 mInformationSecondRowLabel->setPlainText(""); |
470 mInformationLonelyRowLabel->setPlainText(KFmRadioText); |
672 mInformationLonelyRowLabel->setPlainText(KFmRadioText); |
471 changeInformationAreaLayout(OneRow); |
673 changeInformationAreaLayout(OneRow); |
472 break; |
674 break; |
473 case Starting: |
675 case Starting: |
474 mFmRadioState = Starting; |
676 mFmRadioState = Starting; |
475 changeControlButtonState(ChannelsDisabledStop); |
677 //changeControlButtonState(ChannelsDisabledStop); |
|
678 changePlayButtonState(StopDisabled); |
|
679 // TODO: What should the stop button do? Should it close the radio? |
|
680 changeChannelButtonsEnabledState(false); |
476 changeInformationAreaLayout(Animation); |
681 changeInformationAreaLayout(Animation); |
477 break; |
682 break; |
478 case Running: |
683 case Running: |
479 mFmRadioState = Running; |
684 mFmRadioState = Running; |
480 changeControlButtonState(ChannelsEnabledStop); |
685 mRadioServiceClient->startMonitoring(FmRadioHsWidgetRadioServiceClient::DoNotChange); |
|
686 //changeControlButtonState(ChannelsEnabledStop); |
|
687 QObject::disconnect(mPlayPushButton, SIGNAL(clicked()), this, |
|
688 SLOT(radioToBackground())); |
|
689 QObject::disconnect(mPlayPushButton, SIGNAL(clicked()), this, |
|
690 SLOT(unMute())); |
|
691 QObject::connect(mPlayPushButton, SIGNAL(clicked()), this, |
|
692 SLOT(mute())); |
|
693 changePlayButtonState(StopEnabled); |
|
694 changeChannelButtonsEnabledState(mIsFavoriteChannels); |
481 changeInformationAreaLayout(OneRow); |
695 changeInformationAreaLayout(OneRow); |
482 break; |
696 break; |
483 case ControllingAudio: |
697 case ControllingAudio: |
484 // TODO: Implement |
698 mFmRadioState = ControllingAudio; |
485 changeControlButtonState(ChannelsEnabledStop); |
699 //changeControlButtonState(ChannelsEnabledStop); |
|
700 QObject::disconnect(mPlayPushButton, SIGNAL(clicked()), this, |
|
701 SLOT(radioToBackground())); |
|
702 QObject::disconnect(mPlayPushButton, SIGNAL(clicked()), this, |
|
703 SLOT(unMute())); |
|
704 QObject::connect(mPlayPushButton, SIGNAL(clicked()), this, |
|
705 SLOT(mute())); |
|
706 changePlayButtonState(StopEnabled); |
|
707 changeChannelButtonsEnabledState(mIsFavoriteChannels); |
|
708 radioInformationChanged(); |
486 break; |
709 break; |
487 case NotControllingAudio: |
710 case NotControllingAudio: |
488 // TODO: Implement |
711 mFmRadioState = NotControllingAudio; |
489 changeControlButtonState(ChannelsEnabledPlay); |
712 //changeControlButtonState(ChannelsEnabledPlay); |
490 break; |
713 QObject::disconnect(mPlayPushButton, SIGNAL(clicked()), this, |
491 case AutoScanning: |
714 SLOT(radioToBackground())); |
492 // TODO: Implement |
715 QObject::disconnect(mPlayPushButton, SIGNAL(clicked()), this, |
493 break; |
716 SLOT(mute())); |
494 case ConnectType1Headset: |
717 QObject::connect(mPlayPushButton, SIGNAL(clicked()), this, |
495 // TODO: Implement |
718 SLOT(unMute())); |
496 break; |
719 changePlayButtonState(PlayEnabled); |
497 case ConnectType2Headset: |
720 changeChannelButtonsEnabledState(mIsFavoriteChannels); |
498 // TODO: Implement |
721 radioInformationChanged(); |
499 break; |
722 break; |
500 case ConnectType3Headset: |
723 case Seeking: |
501 // TODO: Implement |
724 mFmRadioState = Seeking; |
|
725 //changeControlButtonState(AllDisabledStop); |
|
726 changePlayButtonState(StopDisabled); |
|
727 changeChannelButtonsEnabledState(false); |
|
728 changeInformationAreaLayout(Animation); |
|
729 break; |
|
730 case AntennaNotConnected: |
|
731 mFmRadioState = AntennaNotConnected; |
|
732 //changeControlButtonState(AllDisabledPlay); |
|
733 changePlayButtonState(StopDisabled); |
|
734 changeChannelButtonsEnabledState(false); |
|
735 mInformationFirstRowLabel->setPlainText(""); |
|
736 mInformationSecondRowLabel->setPlainText(""); |
|
737 mInformationLonelyRowLabel->setPlainText(KConnectHeadsetText); |
|
738 changeInformationAreaLayout(OneRow); |
502 break; |
739 break; |
503 default: |
740 default: |
504 break; |
741 break; |
505 } |
742 } |
506 } |
743 } |
541 void FmRadioHsWidget::changeControlButtonState(ControlButtonState buttonState) |
778 void FmRadioHsWidget::changeControlButtonState(ControlButtonState buttonState) |
542 { |
779 { |
543 QString iconName; |
780 QString iconName; |
544 switch (buttonState) { |
781 switch (buttonState) { |
545 case AllDisabledPlay: |
782 case AllDisabledPlay: |
546 mPreviousPushButton->setEnabled(false); |
783 changeControlButtonFrameBackground(false, Left, mPreviousPushButton); |
547 iconName.append("qtg_mono_play"); |
784 iconName.append("qtg_mono_play"); |
548 mPlayPushButton->setIcon(HbIcon(iconName)); |
785 mPlayPushButton->setIcon(HbIcon(iconName)); |
549 mPlayPushButton->setEnabled(false); |
786 changeControlButtonFrameBackground(false, Center, mPlayPushButton); |
550 mNextPushButton->setEnabled(false); |
787 changeControlButtonFrameBackground(false, Right, mNextPushButton); |
551 break; |
788 break; |
552 case AllDisabledStop: |
789 case AllDisabledStop: |
553 mPreviousPushButton->setEnabled(false); |
790 changeControlButtonFrameBackground(false, Left, mPreviousPushButton); |
554 iconName.append("qtg_mono_stop"); |
791 iconName.append("qtg_mono_stop"); |
555 mPlayPushButton->setIcon(HbIcon(iconName)); |
792 mPlayPushButton->setIcon(HbIcon(iconName)); |
556 mPlayPushButton->setEnabled(false); |
793 changeControlButtonFrameBackground(false, Center, mPlayPushButton); |
557 mNextPushButton->setEnabled(false); |
794 changeControlButtonFrameBackground(false, Right, mNextPushButton); |
558 break; |
795 break; |
559 case ChannelsDisabledPlay: |
796 case ChannelsDisabledPlay: |
560 mPreviousPushButton->setEnabled(false); |
797 changeControlButtonFrameBackground(false, Left, mPreviousPushButton); |
561 QObject::disconnect(mPlayPushButton, SIGNAL(clicked()), this, |
798 QObject::disconnect(mPlayPushButton, SIGNAL(clicked()), this, |
562 SLOT(unMute())); |
799 SLOT(unMute())); |
563 QObject::disconnect(mPlayPushButton, SIGNAL(clicked()), this, |
800 QObject::disconnect(mPlayPushButton, SIGNAL(clicked()), this, |
564 SLOT(mute())); |
801 SLOT(mute())); |
565 QObject::connect(mPlayPushButton, SIGNAL(clicked()), this, |
802 QObject::connect(mPlayPushButton, SIGNAL(clicked()), this, |
566 SLOT(radioToBackground())); |
803 SLOT(radioToBackground())); |
567 iconName.append("qtg_mono_play"); |
804 iconName.append("qtg_mono_play"); |
568 mPlayPushButton->setIcon(HbIcon(iconName)); |
805 mPlayPushButton->setIcon(HbIcon(iconName)); |
569 mPlayPushButton->setEnabled(true); |
806 changeControlButtonFrameBackground(true, Center, mPlayPushButton); |
570 mNextPushButton->setEnabled(false); |
807 changeControlButtonFrameBackground(false, Right, mNextPushButton); |
571 break; |
808 break; |
572 case ChannelsDisabledStop: |
809 case ChannelsDisabledStop: |
573 mPreviousPushButton->setEnabled(false); |
810 changeControlButtonFrameBackground(false, Left, mPreviousPushButton); |
574 iconName.append("qtg_mono_stop"); |
811 iconName.append("qtg_mono_stop"); |
575 mPlayPushButton->setIcon(HbIcon(iconName)); |
812 mPlayPushButton->setIcon(HbIcon(iconName)); |
576 mPlayPushButton->setEnabled(true); |
813 changeControlButtonFrameBackground(true, Center, mPlayPushButton); |
577 mNextPushButton->setEnabled(false); |
814 changeControlButtonFrameBackground(false, Right, mNextPushButton); |
578 break; |
815 break; |
579 case ChannelsEnabledPlay: |
816 case ChannelsEnabledPlay: |
580 mPreviousPushButton->setEnabled(true); |
817 changeControlButtonFrameBackground(true, Left, mPreviousPushButton); |
581 QObject::disconnect(mPlayPushButton, SIGNAL(clicked()), this, |
818 QObject::disconnect(mPlayPushButton, SIGNAL(clicked()), this, |
582 SLOT(radioToBackground())); |
819 SLOT(radioToBackground())); |
583 QObject::disconnect(mPlayPushButton, SIGNAL(clicked()), this, |
820 QObject::disconnect(mPlayPushButton, SIGNAL(clicked()), this, |
584 SLOT(mute())); |
821 SLOT(mute())); |
585 QObject::connect(mPlayPushButton, SIGNAL(clicked()), this, |
822 QObject::connect(mPlayPushButton, SIGNAL(clicked()), this, |
586 SLOT(unMute())); |
823 SLOT(unMute())); |
587 iconName.append("qtg_mono_play"); |
824 iconName.append("qtg_mono_play"); |
588 mPlayPushButton->setIcon(HbIcon(iconName)); |
825 mPlayPushButton->setIcon(HbIcon(iconName)); |
589 mPlayPushButton->setEnabled(true); |
826 changeControlButtonFrameBackground(true, Center, mPlayPushButton); |
590 mNextPushButton->setEnabled(true); |
827 changeControlButtonFrameBackground(true, Right, mNextPushButton); |
591 break; |
828 break; |
592 case ChannelsEnabledStop: |
829 case ChannelsEnabledStop: |
593 mPreviousPushButton->setEnabled(true); |
830 changeControlButtonFrameBackground(true, Left, mPreviousPushButton); |
594 QObject::disconnect(mPlayPushButton, SIGNAL(clicked()), this, |
831 QObject::disconnect(mPlayPushButton, SIGNAL(clicked()), this, |
595 SLOT(radioToBackground())); |
832 SLOT(radioToBackground())); |
596 QObject::disconnect(mPlayPushButton, SIGNAL(clicked()), this, |
833 QObject::disconnect(mPlayPushButton, SIGNAL(clicked()), this, |
597 SLOT(unMute())); |
834 SLOT(unMute())); |
598 QObject::connect(mPlayPushButton, SIGNAL(clicked()), this, |
835 QObject::connect(mPlayPushButton, SIGNAL(clicked()), this, |
599 SLOT(mute())); |
836 SLOT(mute())); |
600 iconName.append("qtg_mono_stop"); |
837 iconName.append("qtg_mono_stop"); |
601 mPlayPushButton->setIcon(HbIcon(iconName)); |
838 mPlayPushButton->setIcon(HbIcon(iconName)); |
602 mPlayPushButton->setEnabled(true); |
839 changeControlButtonFrameBackground(true, Center, mPlayPushButton); |
603 mNextPushButton->setEnabled(true); |
840 changeControlButtonFrameBackground(true, Right, mNextPushButton); |
604 break; |
841 break; |
605 default: |
842 default: |
606 break; |
843 break; |
607 } |
844 } |
608 } |
845 } |
|
846 |
|
847 /*! |
|
848 Changes enabled state of channel buttons. |
|
849 |
|
850 */ |
|
851 void FmRadioHsWidget::changePlayButtonState(PlayButtonState buttonState) |
|
852 { |
|
853 QString iconName; |
|
854 bool enabled = false; |
|
855 switch (buttonState) { |
|
856 case PlayDisabled: |
|
857 iconName.append("qtg_mono_play"); |
|
858 mPlayPushButton->setIcon(HbIcon(iconName)); |
|
859 enabled = false; |
|
860 break; |
|
861 case PlayEnabled: |
|
862 iconName.append("qtg_mono_play"); |
|
863 mPlayPushButton->setIcon(HbIcon(iconName)); |
|
864 enabled = true; |
|
865 break; |
|
866 case StopDisabled: |
|
867 iconName.append("qtg_mono_stop"); |
|
868 mPlayPushButton->setIcon(HbIcon(iconName)); |
|
869 enabled = false; |
|
870 break; |
|
871 case StopEnabled: |
|
872 iconName.append("qtg_mono_stop"); |
|
873 mPlayPushButton->setIcon(HbIcon(iconName)); |
|
874 enabled = true; |
|
875 break; |
|
876 default: |
|
877 break; |
|
878 } |
|
879 changeControlButtonFrameBackground(enabled, Center, mPlayPushButton); |
|
880 } |
|
881 |
|
882 /*! |
|
883 Changes enabled state of channel buttons. |
|
884 |
|
885 */ |
|
886 void FmRadioHsWidget::changeChannelButtonsEnabledState(bool enabled) |
|
887 { |
|
888 changeControlButtonFrameBackground(enabled, Left, mPreviousPushButton); |
|
889 changeControlButtonFrameBackground(enabled, Right, mNextPushButton); |
|
890 } |
|
891 |
|
892 /*! |
|
893 Changes background of control button. |
|
894 |
|
895 /param enabled Is button enabled or disabled. |
|
896 /param position Position of the control button in button group. |
|
897 /param button The button to change the background. |
|
898 */ |
|
899 void FmRadioHsWidget::changeControlButtonFrameBackground(bool enabled, |
|
900 ControlButtonPosition position, HbPushButton *button) |
|
901 { |
|
902 QString frameGraphicsName("qtg_fr_hsbutton_"); |
|
903 if (enabled) { |
|
904 frameGraphicsName.append("normal"); |
|
905 } else { |
|
906 frameGraphicsName.append("disabled"); |
|
907 } |
|
908 HbFrameDrawer *frameDrawer = new HbFrameDrawer(frameGraphicsName, |
|
909 HbFrameDrawer::ThreePiecesHorizontal); |
|
910 switch (position) { |
|
911 case Left: |
|
912 frameDrawer->setFileNameSuffixList(QStringList() << "_l" << "_c" << "_cr"); |
|
913 break; |
|
914 case Center: |
|
915 frameDrawer->setFileNameSuffixList(QStringList() << "_cl" << "_c" << "_cr"); |
|
916 break; |
|
917 case Right: |
|
918 frameDrawer->setFileNameSuffixList(QStringList() << "_cl" << "_c" << "_r"); |
|
919 break; |
|
920 default: |
|
921 break; |
|
922 } |
|
923 button->setFrameBackground(frameDrawer); |
|
924 button->setEnabled(enabled); |
|
925 } |