64 { |
63 { |
65 if ( scanning ) { |
64 if ( scanning ) { |
66 loadSection( DOCML::FILE_MAINVIEW, DOCML::MV_SECTION_SCANNING ); |
65 loadSection( DOCML::FILE_MAINVIEW, DOCML::MV_SECTION_SCANNING ); |
67 } else { |
66 } else { |
68 loadSection( DOCML::FILE_MAINVIEW, DOCML::MV_SECTION_NORMAL ); |
67 loadSection( DOCML::FILE_MAINVIEW, DOCML::MV_SECTION_NORMAL ); |
|
68 updateFavoriteButton(); |
69 mFrequencyScanner.take(); |
69 mFrequencyScanner.take(); |
70 |
70 |
71 const bool firsTimeStart = mUiEngine->isFirstTimeStart(); |
71 const bool firsTimeStart = mUiEngine->isFirstTimeStart(); |
72 const int rowCount = mUiEngine->stationModel().rowCount(); |
72 const int rowCount = mUiEngine->stationModel().rowCount(); |
73 if ( firsTimeStart && rowCount != 0 ) { |
73 if ( firsTimeStart && rowCount != 0 ) { |
85 LOG_METHOD; |
85 LOG_METHOD; |
86 loadSection( DOCML::FILE_MAINVIEW, DOCML::SECTION_LAZY_LOAD ); |
86 loadSection( DOCML::FILE_MAINVIEW, DOCML::SECTION_LAZY_LOAD ); |
87 mCarousel = mUiLoader->findObject<RadioStationCarousel>( DOCML::MV_NAME_STATION_CAROUSEL ); |
87 mCarousel = mUiLoader->findObject<RadioStationCarousel>( DOCML::MV_NAME_STATION_CAROUSEL ); |
88 mCarousel->init( *mUiLoader, mUiEngine.data() ); |
88 mCarousel->init( *mUiLoader, mUiEngine.data() ); |
89 |
89 |
90 // Note! UI connections are already made in the DocML file. Here we need to connect UI to engine |
|
91 mFrequencyStrip = mUiLoader->findObject<RadioFrequencyStrip>( DOCML::MV_NAME_FREQUENCY_STRIP ); |
90 mFrequencyStrip = mUiLoader->findObject<RadioFrequencyStrip>( DOCML::MV_NAME_FREQUENCY_STRIP ); |
92 mFrequencyStrip->init( mUiEngine.data(), *mUiLoader ); |
91 mFrequencyStrip->init( mUiEngine.data(), *mUiLoader ); |
93 |
92 |
94 RadioStationModel* stationModel = &mUiEngine->stationModel(); |
93 RadioStationModel* stationModel = &mUiEngine->stationModel(); |
95 |
94 |
120 this, SLOT(handleFavoriteChange(RadioStation)) ); |
119 this, SLOT(handleFavoriteChange(RadioStation)) ); |
121 |
120 |
122 connectXmlElement( DOCML::MV_NAME_STATIONS_BUTTON, SIGNAL(clicked()), |
121 connectXmlElement( DOCML::MV_NAME_STATIONS_BUTTON, SIGNAL(clicked()), |
123 mMainWindow, SLOT(activateStationsView()) ); |
122 mMainWindow, SLOT(activateStationsView()) ); |
124 |
123 |
125 connectXmlElement( DOCML::MV_NAME_SCAN_BUTTON, SIGNAL(clicked()), |
124 connectXmlElement( DOCML::MV_NAME_FAVORITE_BUTTON, SIGNAL(clicked()), |
126 this, SLOT(toggleScanning()) ); |
125 this, SLOT(toggleFavorite()) ); |
127 |
126 |
128 connectXmlElement( DOCML::MV_NAME_SPEAKER_BUTTON, SIGNAL(clicked()), |
127 connectXmlElement( DOCML::MV_NAME_SPEAKER_BUTTON, SIGNAL(clicked()), |
129 mUiEngine.data(), SLOT(toggleAudioRoute()) ); |
128 mUiEngine.data(), SLOT(toggleAudioRoute()) ); |
130 |
129 |
|
130 connectXmlElement( DOCML::MV_NAME_SCAN_ACTION, SIGNAL(triggered()), |
|
131 this, SLOT(toggleScanning()) ); |
|
132 |
|
133 updateFavoriteButton(); |
|
134 |
131 connectCommonMenuItem( MenuItem::Exit ); |
135 connectCommonMenuItem( MenuItem::Exit ); |
132 |
136 |
133 // "Play history" menu item |
137 // "Play history" menu item |
134 connectViewChangeMenuItem( DOCML::MV_NAME_HISTORYVIEW_ACTION, SLOT(activateHistoryView()) ); |
138 connectViewChangeMenuItem( DOCML::MV_NAME_HISTORYVIEW_ACTION, SLOT(activateHistoryView()) ); |
135 |
139 |
136 //TODO: REMOVE. THIS IS TEMPORARY TEST CODE |
140 //TODO: REMOVE. THIS IS TEMPORARY TEST CODE |
137 toggleSkippingMode(); |
141 toggleSkippingMode(); |
138 menu()->addAction( "Reset start count", this, SLOT(resetFirstTimeCount()) ); |
142 menu()->addAction( "-- Reset start count", this, SLOT(resetFirstTimeCount()) ); |
139 // END TEMPORARY TEST CODE |
143 // END TEMPORARY TEST CODE |
140 |
144 |
141 updateAudioRoute( mUiEngine->isUsingLoudspeaker() ); |
145 updateAudioRoute( mUiEngine->isUsingLoudspeaker() ); |
142 |
146 |
143 // Add "back" navigation action to put the application to background |
147 // Add "back" navigation action to put the application to background |
221 * Private slot |
225 * Private slot |
222 */ |
226 */ |
223 void RadioMainView::setFrequencyFromEngine( uint frequency, int reason ) |
227 void RadioMainView::setFrequencyFromEngine( uint frequency, int reason ) |
224 { |
228 { |
225 LOG_FORMAT( "RadioMainView::setFrequencyFromEngine reason: %d", reason ); |
229 LOG_FORMAT( "RadioMainView::setFrequencyFromEngine reason: %d", reason ); |
226 if ( !RadioUtil::isScannerAlive() && !mFrequencyStrip->isInManualSeekMode() ) { |
230 if ( RadioUtil::scanStatus() != Scan::ScanningInMainView && !mFrequencyStrip->isInManualSeekMode() ) { |
227 mCarousel->clearInfoText(); |
231 mCarousel->clearInfoText(); |
|
232 updateFavoriteButton(); |
228 if ( reason != TuneReason::FrequencyStrip && |
233 if ( reason != TuneReason::FrequencyStrip && |
229 reason != TuneReason::StationCarousel && |
234 reason != TuneReason::StationCarousel && |
230 reason != TuneReason::Skip ) { |
235 reason != TuneReason::Skip ) { |
231 mCarousel->setFrequency( frequency, reason, Scroll::Shortest ); |
236 mCarousel->setFrequency( frequency, reason, Scroll::Shortest ); |
232 mFrequencyStrip->setFrequency( frequency, reason, Scroll::Shortest ); |
237 mFrequencyStrip->setFrequency( frequency, reason, Scroll::Shortest ); |
345 */ |
362 */ |
346 void RadioMainView::setManualSeekMode( bool manualSeekActive ) |
363 void RadioMainView::setManualSeekMode( bool manualSeekActive ) |
347 { |
364 { |
348 if ( manualSeekActive ) { |
365 if ( manualSeekActive ) { |
349 qApp->installEventFilter( this ); |
366 qApp->installEventFilter( this ); |
|
367 |
|
368 mUiLoader->findWidget<HbPushButton>( DOCML::MV_NAME_FAVORITE_BUTTON )->setText( hbTrId( "txt_rad_button_add_to_favourites" ) ); |
350 } else { |
369 } else { |
351 qApp->removeEventFilter( this ); |
370 qApp->removeEventFilter( this ); |
|
371 |
|
372 updateFavoriteButton(); |
352 } |
373 } |
353 |
374 |
354 mUiEngine->setManualSeekMode( manualSeekActive ); |
375 mUiEngine->setManualSeekMode( manualSeekActive ); |
355 |
376 |
356 mCarousel->setManualSeekMode( manualSeekActive ); |
377 mCarousel->setManualSeekMode( manualSeekActive ); |
379 } |
396 } |
380 |
397 |
381 mAlternateSkipping = !mAlternateSkipping; |
398 mAlternateSkipping = !mAlternateSkipping; |
382 mCarousel->setAlternateSkippingMode( mAlternateSkipping ); |
399 mCarousel->setAlternateSkippingMode( mAlternateSkipping ); |
383 if ( mAlternateSkipping ) { |
400 if ( mAlternateSkipping ) { |
384 mSkippingAction->setText( "Normal skipping mode" ); |
401 mSkippingAction->setText( "-- Normal skipping mode" ); |
385 } else { |
402 } else { |
386 mSkippingAction->setText( "Alternate skipping mode" ); |
403 mSkippingAction->setText( "-- Alternate skipping mode" ); |
387 } |
404 } |
388 } |
405 } |
389 |
406 |
390 /*! |
407 /*! |
391 * Private slot |
408 * Private slot |
392 */ |
409 */ |
393 void RadioMainView::resetFirstTimeCount() |
410 void RadioMainView::resetFirstTimeCount() |
394 { |
411 { |
395 mUiEngine->setFirstTimeStartPerformed( false ); |
412 mUiEngine->setFirstTimeStartPerformed( false ); |
396 } |
413 } |
|
414 |
|
415 /*! |
|
416 * |
|
417 */ |
|
418 void RadioMainView::updateFavoriteButton() |
|
419 { |
|
420 RadioStation station; |
|
421 RadioStationModel& model = mUiEngine->stationModel(); |
|
422 model.findFrequency( mUiEngine->currentFrequency(), station ); |
|
423 HbPushButton* favoriteButton = mUiLoader->findWidget<HbPushButton>( DOCML::MV_NAME_FAVORITE_BUTTON ); |
|
424 if ( station.isFavorite() ) { |
|
425 //TODO: Get localized text |
|
426 favoriteButton->setText( "Remove from favourites" ); |
|
427 // favoriteButton->setIcon( HbIcon( ":/images/pri_small_star_inactive.svg" ) ); |
|
428 } else { |
|
429 favoriteButton->setText( hbTrId( "txt_rad_button_add_to_favourites" ) ); |
|
430 // favoriteButton->setIcon( HbIcon( ":/images/pri_small_star.svg" ) ); |
|
431 } |
|
432 } |