radioapp/radiowidgets/src/radiomainview.cpp
changeset 44 0a3ad94fc71c
parent 39 ac7857bd5fdb
child 51 bbebb0235466
equal deleted inserted replaced
39:ac7857bd5fdb 44:0a3ad94fc71c
   169     connectCommonMenuItem( MenuItem::Exit );
   169     connectCommonMenuItem( MenuItem::Exit );
   170 
   170 
   171     // "Play history" menu item
   171     // "Play history" menu item
   172     connectViewChangeMenuItem( DOCML::MV_NAME_HISTORYVIEW_ACTION, SLOT(activateHistoryView()) );
   172     connectViewChangeMenuItem( DOCML::MV_NAME_HISTORYVIEW_ACTION, SLOT(activateHistoryView()) );
   173 
   173 
   174     //TODO: REMOVE. THIS IS TEMPORARY TEST CODE
       
   175     toggleSkippingMode();
       
   176     menu()->addAction( "-- Reset start count", this, SLOT(resetFirstTimeCount()) );
       
   177     // END TEMPORARY TEST CODE
       
   178 
       
   179     updateAudioRoute( mUiEngine->isUsingLoudspeaker() );
   174     updateAudioRoute( mUiEngine->isUsingLoudspeaker() );
   180 
   175 
   181     // Add "back" navigation action to put the application to background
   176     // Add "back" navigation action to put the application to background
   182     HbAction* backAction = new HbAction( Hb::BackNaviAction, this );
   177     HbAction* backAction = new HbAction( Hb::BackNaviAction, this );
   183 #ifdef BUILD_WIN32
   178 #ifdef BUILD_WIN32
   189 #endif // BUILD_WIN32
   184 #endif // BUILD_WIN32
   190     setNavigationAction( backAction );
   185     setNavigationAction( backAction );
   191 
   186 
   192     const bool firsTimeStart = mUiEngine->isFirstTimeStart();
   187     const bool firsTimeStart = mUiEngine->isFirstTimeStart();
   193     const int rowCount = mUiEngine->stationModel().rowCount();
   188     const int rowCount = mUiEngine->stationModel().rowCount();
   194     if ( firsTimeStart && rowCount == 0 ){
   189 
   195         QTimer::singleShot( 100, this, SLOT(toggleScanning()) );
   190    if ( firsTimeStart && rowCount == 0 ){
   196     }
   191             QTimer::singleShot( 4500, this, SLOT(startFirstTimeScanning()) );
       
   192         }
       
   193 
   197 
   194 
   198     Radio::connect( static_cast<HbApplication*>( qApp ),    SIGNAL(aboutToQuit()),
   195     Radio::connect( static_cast<HbApplication*>( qApp ),    SIGNAL(aboutToQuit()),
   199                     this,                                   SLOT(saveActivity()) );
   196                     this,                                   SLOT(saveActivity()) );
   200 
   197 
   201     emit applicationReady();
   198     emit applicationReady();
   327 }
   324 }
   328 
   325 
   329 /*!
   326 /*!
   330  * Private slot
   327  * Private slot
   331  */
   328  */
       
   329 void RadioMainView::startFirstTimeScanning()
       
   330 {
       
   331     if ( mUiEngine->isAntennaAttached() ){
       
   332         QTimer::singleShot( 100, this, SLOT(toggleScanning()) );
       
   333     }
       
   334 }
       
   335 
       
   336 /*!
       
   337  * Private slot
       
   338  */
   332 void RadioMainView::toggleScanning()
   339 void RadioMainView::toggleScanning()
   333 {
   340 {
   334     mFrequencyStrip->cancelManualSeek();
   341     mFrequencyStrip->cancelManualSeek();
   335     if ( mFrequencyScanner ) {
   342     if ( mFrequencyScanner ) {
   336         mFrequencyScanner->cancelScanning();
   343         mFrequencyScanner->cancelScanning();
   376     }
   383     }
   377 
   384 
   378     HbAction* scanAction = mUiLoader->findObject<HbAction>( DOCML::MV_NAME_SCAN_ACTION );
   385     HbAction* scanAction = mUiLoader->findObject<HbAction>( DOCML::MV_NAME_SCAN_ACTION );
   379     scanAction->setEnabled( connected );
   386     scanAction->setEnabled( connected );
   380     mCarousel->updateAntennaStatus( connected );
   387     mCarousel->updateAntennaStatus( connected );
       
   388     const bool firsTimeStart = mUiEngine->isFirstTimeStart();
       
   389     const int rowCount = mUiEngine->stationModel().rowCount();
       
   390     if ( firsTimeStart && rowCount == 0 && connected ){
       
   391             QTimer::singleShot( 100, this, SLOT(toggleScanning()) );
       
   392         }
   381 }
   393 }
   382 
   394 
   383 /*!
   395 /*!
   384  * Private slot
   396  * Private slot
   385  */
   397  */
   456     // Update the activity to the activity manager
   468     // Update the activity to the activity manager
   457     bool ok = activityManager->removeActivity( RADIO_MAINVIEW_ACTIVITY_ID );
   469     bool ok = activityManager->removeActivity( RADIO_MAINVIEW_ACTIVITY_ID );
   458     LOG_ASSERT( ok, LOG( "Failed to remove old activity from Activity Manager!" ) );
   470     LOG_ASSERT( ok, LOG( "Failed to remove old activity from Activity Manager!" ) );
   459     ok = activityManager->addActivity( RADIO_MAINVIEW_ACTIVITY_ID, QVariant(), metadata );
   471     ok = activityManager->addActivity( RADIO_MAINVIEW_ACTIVITY_ID, QVariant(), metadata );
   460     LOG_ASSERT( ok, LOG( "Failed to update activity to Activity Manager!" ) );
   472     LOG_ASSERT( ok, LOG( "Failed to update activity to Activity Manager!" ) );
   461 }
       
   462 
       
   463 /*!
       
   464  * Private slot
       
   465  */
       
   466 void RadioMainView::toggleSkippingMode()
       
   467 {
       
   468     if ( !mSkippingAction ) {
       
   469         mSkippingAction = menu()->addAction( "", this, SLOT(toggleSkippingMode()) );
       
   470     }
       
   471 
       
   472     mAlternateSkipping = !mAlternateSkipping;
       
   473     mCarousel->setAlternateSkippingMode( mAlternateSkipping );
       
   474     if ( mAlternateSkipping ) {
       
   475         mSkippingAction->setText( "-- Normal skipping mode" );
       
   476     } else {
       
   477         mSkippingAction->setText( "-- Alternate skipping mode" );
       
   478     }
       
   479 }
       
   480 
       
   481 /*!
       
   482  * Private slot
       
   483  */
       
   484 void RadioMainView::resetFirstTimeCount()
       
   485 {
       
   486     mUiEngine->setFirstTimeStartPerformed( false );
       
   487 }
   473 }
   488 
   474 
   489 /*!
   475 /*!
   490  *
   476  *
   491  */
   477  */