radioapp/radiowidgets/src/radiomainview.cpp
branchGCC_SURGE
changeset 37 451b2e1545b2
parent 33 11b6825f0862
child 41 3a6b55c6390c
equal deleted inserted replaced
26:6bcf277166c1 37:451b2e1545b2
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 // System includes
    18 // System includes
    19 #include <QTimer>
    19 #include <QTimer>
    20 #include <HbLabel>
       
    21 #include <HbPushButton>
    20 #include <HbPushButton>
    22 #include <HbAction>
    21 #include <HbAction>
       
    22 #include <HbMenu>
       
    23 #include <HbApplication>
       
    24 #include <HbActivityManager>
       
    25 #include <QPixmap>
       
    26 #include <HbLabel>
       
    27 #include <HbFrameItem>          // Temporarily here until docml supports frame items
    23 
    28 
    24 // User includes
    29 // User includes
    25 #include "radiowindow.h"
    30 #include "radiowindow.h"
    26 #include "radiomainview.h"
    31 #include "radiomainview.h"
    27 #include "radiofrequencystrip.h"
    32 #include "radiofrequencystrip.h"
    28 #include "radiouiengine.h"
    33 #include "radiouiengine.h"
    29 #include "radiologger.h"
    34 #include "radiologger.h"
    30 #include "radiostationcarousel.h"
    35 #include "radiostationcarousel.h"
    31 #include "radiouiloader.h"
    36 #include "radiouiloader.h"
    32 #include "radiouiutilities.h"
    37 #include "radioutil.h"
    33 #include "radiostationmodel.h"
    38 #include "radiostationmodel.h"
    34 #include "radiofrequencyscanner.h"
    39 #include "radiofrequencyscanner.h"
    35 
    40 
    36 // Constants
    41 // Constants
       
    42 const QLatin1String RADIO_MAINVIEW_ACTIVITY_ID( "FMRadioMainView" );
       
    43 
       
    44 /*!
       
    45  * Temporary convenience function to set frame background until DOCML supports frame items
       
    46  */
       
    47 static void initFrameBackground( RadioUiLoader& uiLoader,
       
    48                                  const QString backgroundName,
       
    49                                  HbFrameDrawer::FrameType frameType )
       
    50 {
       
    51     if ( HbLabel* backgroundLabel = uiLoader.findObject<HbLabel>( backgroundName ) ) {
       
    52         QString backgroundName = backgroundLabel->icon().iconName();
       
    53         HbFrameItem* frameItem = new HbFrameItem( backgroundName, frameType, backgroundLabel );
       
    54         backgroundLabel->setBackgroundItem( frameItem );
       
    55     }
       
    56 }
       
    57 
    37 
    58 
    38 /*!
    59 /*!
    39  *
    60  *
    40  */
    61  */
    41 RadioMainView::RadioMainView() :
    62 RadioMainView::RadioMainView() :
    42     RadioViewBase( false ),
    63     RadioViewBase( false ),
    43     mCarousel( NULL ),
    64     mCarousel( NULL ),
    44     mFrequencyStrip( NULL )
    65     mFrequencyStrip( NULL ),
       
    66     mSkippingAction( NULL ),
       
    67     mAlternateSkipping( false )
    45 {
    68 {
    46 }
    69 }
    47 
    70 
    48 /*!
    71 /*!
    49  *
    72  *
    60 {
    83 {
    61     if ( scanning ) {
    84     if ( scanning ) {
    62         loadSection( DOCML::FILE_MAINVIEW, DOCML::MV_SECTION_SCANNING );
    85         loadSection( DOCML::FILE_MAINVIEW, DOCML::MV_SECTION_SCANNING );
    63     } else {
    86     } else {
    64         loadSection( DOCML::FILE_MAINVIEW, DOCML::MV_SECTION_NORMAL );
    87         loadSection( DOCML::FILE_MAINVIEW, DOCML::MV_SECTION_NORMAL );
       
    88         updateFavoriteButton();
    65         mFrequencyScanner.take();
    89         mFrequencyScanner.take();
       
    90 
       
    91 //        const bool firsTimeStart = mUiEngine->isFirstTimeStart();
       
    92         const bool firsTimeStart = false; // TODO! RadioServer terminates. Fix available in NCP 25 or 27.
       
    93         const int rowCount = mUiEngine->stationModel().rowCount();
       
    94         if ( firsTimeStart && rowCount != 0 ) {
       
    95             mUiEngine->setFirstTimeStartPerformed( true );
       
    96         }
    66     }
    97     }
    67 }
    98 }
    68 
    99 
    69 /*!
   100 /*!
    70  * \reimp
   101  * \reimp
    71  *
   102  *
    72  */
   103  */
       
   104 void RadioMainView::preLazyLoadInit()
       
   105 {
       
   106     initFrameBackground( *mUiLoader, DOCML::MV_NAME_FREQUENCY_BACKGROUND, HbFrameDrawer::NinePieces );
       
   107 
       
   108     initFrameBackground( *mUiLoader, DOCML::MV_NAME_CAROUSEL_BACKGROUND, HbFrameDrawer::NinePieces );
       
   109 }
       
   110 
       
   111 /*!
       
   112  * \reimp
       
   113  *
       
   114  */
    73 void RadioMainView::init()
   115 void RadioMainView::init()
    74 {
   116 {
    75     LOG_METHOD;
   117     LOG_METHOD;
    76     mInitialized = true;
   118     loadSection( DOCML::FILE_MAINVIEW, DOCML::SECTION_LAZY_LOAD );
       
   119     initFrameBackground( *mUiLoader, DOCML::MV_NAME_CAROUSEL_OVERLAY, HbFrameDrawer::NinePieces );
       
   120 
    77     mCarousel = mUiLoader->findObject<RadioStationCarousel>( DOCML::MV_NAME_STATION_CAROUSEL );
   121     mCarousel = mUiLoader->findObject<RadioStationCarousel>( DOCML::MV_NAME_STATION_CAROUSEL );
    78     mCarousel->init( *mUiLoader, &mMainWindow->uiEngine() );
   122     mCarousel->init( *mUiLoader, mUiEngine.data() );
    79 
   123 
    80     // Note! UI connections are already made in the DocML file. Here we need to connect UI to engine
       
    81     RadioUiEngine* engine = &mMainWindow->uiEngine();
       
    82     mFrequencyStrip = mUiLoader->findObject<RadioFrequencyStrip>( DOCML::MV_NAME_FREQUENCY_STRIP );
   124     mFrequencyStrip = mUiLoader->findObject<RadioFrequencyStrip>( DOCML::MV_NAME_FREQUENCY_STRIP );
    83     mFrequencyStrip->init( engine );
   125     mFrequencyStrip->init( mUiEngine.data(), *mUiLoader );
    84 
   126 
    85     RadioStationModel* stationModel = &engine->stationModel();
   127     RadioStationModel* stationModel = &mUiEngine->stationModel();
    86 
   128 
    87     connectAndTest( mFrequencyStrip,            SIGNAL(frequencyChanged(uint,int)),
   129     Radio::connect( mFrequencyStrip,            SIGNAL(frequencyChanged(uint,int,int)),
    88                     this,                       SLOT(setFrequencyFromWidget(uint,int)) );
   130                     this,                       SLOT(setFrequencyFromWidget(uint,int,int)) );
    89     connectAndTest( mCarousel,                  SIGNAL(frequencyChanged(uint,int)),
   131     Radio::connect( mCarousel,                  SIGNAL(frequencyChanged(uint,int,int)),
    90                     this,                       SLOT(setFrequencyFromWidget(uint,int)) );
   132                     this,                       SLOT(setFrequencyFromWidget(uint,int,int)) );
    91     connectAndTest( engine,                     SIGNAL(tunedToFrequency(uint,int)),
   133     Radio::connect( mUiEngine.data(),           SIGNAL(tunedToFrequency(uint,int)),
    92                     this,                       SLOT(setFrequencyFromEngine(uint,int)) );
   134                     this,                       SLOT(setFrequencyFromEngine(uint,int)) );
    93 
   135     Radio::connect( mFrequencyStrip,            SIGNAL(manualSeekChanged(bool)),
    94     connectAndTest( mFrequencyStrip,            SIGNAL(skipRequested(int)),
   136                     this,                       SLOT(setManualSeekMode(bool)) );
       
   137 
       
   138     Radio::connect( mFrequencyStrip,            SIGNAL(skipRequested(int)),
    95                     this,                       SLOT(skip(int)) );
   139                     this,                       SLOT(skip(int)) );
    96     connectAndTest( mFrequencyStrip,            SIGNAL(seekRequested(int)),
   140     Radio::connect( mCarousel,                  SIGNAL(skipRequested(int)),
    97                     engine,                     SLOT(seekStation(int)) );
   141                     this,                       SLOT(skip(int)) );
    98 
   142     Radio::connect( mFrequencyStrip,            SIGNAL(seekRequested(int)),
    99     connectAndTest( stationModel,               SIGNAL(favoriteChanged(RadioStation)),
   143                     mUiEngine.data(),           SLOT(seekStation(int)) );
   100                     mFrequencyStrip,            SLOT(updateFavorite(RadioStation)) );
   144 
   101 
   145     Radio::connect( mUiEngine.data(),           SIGNAL(seekingStarted(int)),
   102     connectAndTest( engine,                     SIGNAL(seekingStarted(int)),
       
   103                     this,                       SLOT(seekingStarted()) );
   146                     this,                       SLOT(seekingStarted()) );
   104     connectAndTest( engine,                     SIGNAL(antennaStatusChanged(bool)),
   147     Radio::connect( mUiEngine.data(),           SIGNAL(antennaStatusChanged(bool)),
   105                     mCarousel,                  SLOT(updateAntennaStatus(bool)) );
   148                     this,                       SLOT(updateAntennaStatus(bool)) );
   106     connectAndTest( engine,                     SIGNAL(audioRouteChanged(bool)),
   149     Radio::connect( mUiEngine.data(),           SIGNAL(audioRouteChanged(bool)),
   107                     this,                       SLOT(updateAudioRoute(bool)) );
   150                     this,                       SLOT(updateAudioRoute(bool)) );
   108 
   151 
   109     HbPushButton* stationsButton = mUiLoader->findWidget<HbPushButton>( DOCML::MV_NAME_STATIONS_BUTTON );
   152     Radio::connect( stationModel,               SIGNAL(favoriteChanged(RadioStation)),
   110     connectAndTest( stationsButton,             SIGNAL(clicked()),
   153                     this,                       SLOT(handleFavoriteChange(RadioStation)) );
   111                     mMainWindow,                SLOT(activateStationsView()) );
   154 
   112 
   155     connectXmlElement( DOCML::MV_NAME_STATIONS_BUTTON,  SIGNAL(clicked()),
   113     HbPushButton* scanButton = mUiLoader->findWidget<HbPushButton>( DOCML::MV_NAME_SCAN_BUTTON );
   156                        mMainWindow,                     SLOT(activateStationsView()) );
   114     connectAndTest( scanButton,                 SIGNAL(clicked()),
   157 
   115                     this,                       SLOT(toggleScanning()) );
   158     connectXmlElement( DOCML::MV_NAME_FAVORITE_BUTTON,  SIGNAL(clicked()),
   116 
   159                        this,                            SLOT(toggleFavorite()) );
   117     HbPushButton* loudspeakerButton = mUiLoader->findWidget<HbPushButton>( DOCML::MV_NAME_SPEAKER_BUTTON );
   160 
   118     connectAndTest( loudspeakerButton,          SIGNAL(clicked()),
   161     connectXmlElement( DOCML::MV_NAME_SPEAKER_BUTTON,   SIGNAL(clicked()),
   119                     engine,                     SLOT(toggleAudioRoute()) );
   162                        mUiEngine.data(),                SLOT(toggleAudioRoute()) );
       
   163 
       
   164     connectXmlElement( DOCML::MV_NAME_SCAN_ACTION,      SIGNAL(triggered()),
       
   165                        this,                            SLOT(toggleScanning()) );
       
   166 
       
   167     updateFavoriteButton();
       
   168 
       
   169     connectCommonMenuItem( MenuItem::Exit );
   120 
   170 
   121     // "Play history" menu item
   171     // "Play history" menu item
   122     connectViewChangeMenuItem( DOCML::MV_NAME_HISTORYVIEW_ACTION, SLOT(activateHistoryView()) );
   172     connectViewChangeMenuItem( DOCML::MV_NAME_HISTORYVIEW_ACTION, SLOT(activateHistoryView()) );
   123 
   173 
   124     updateAudioRoute( mMainWindow->uiEngine().isUsingLoudspeaker() );
   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() );
   125 
   180 
   126     // Add "back" navigation action to put the application to background
   181     // Add "back" navigation action to put the application to background
   127     HbAction* backAction = new HbAction( Hb::BackNaviAction, this );
   182     HbAction* backAction = new HbAction( Hb::BackNaviAction, this );
   128     connectAndTest( backAction,     SIGNAL(triggered()),
   183 #ifdef BUILD_WIN32
       
   184     Radio::connect( backAction,     SIGNAL(triggered()),
       
   185                     this,           SLOT(quit()) );
       
   186 #else
       
   187     Radio::connect( backAction,     SIGNAL(triggered()),
   129                     mMainWindow,    SLOT(lower()) );
   188                     mMainWindow,    SLOT(lower()) );
       
   189 #endif // BUILD_WIN32
   130     setNavigationAction( backAction );
   190     setNavigationAction( backAction );
   131 
   191 
   132     const bool firsTimeStart = engine->isFirstTimeStart();
   192 //    const bool firsTimeStart = mUiEngine->isFirstTimeStart();
   133     const int rowCount = engine->stationModel().rowCount();
   193     const bool firsTimeStart = false; // TODO! RadioServer terminates. Fix available in NCP 25 or 27.
       
   194     const int rowCount = mUiEngine->stationModel().rowCount();
   134     if ( firsTimeStart && rowCount == 0 ){
   195     if ( firsTimeStart && rowCount == 0 ){
   135         QTimer::singleShot( 100, this, SLOT(toggleScanning()) );
   196         QTimer::singleShot( 100, this, SLOT(toggleScanning()) );
   136     }
   197     }
       
   198 
       
   199     Radio::connect( static_cast<HbApplication*>( qApp ),    SIGNAL(aboutToQuit()),
       
   200                     this,                                   SLOT(saveActivity()) );
       
   201 
       
   202     emit applicationReady();
   137 }
   203 }
   138 
   204 
   139 /*!
   205 /*!
   140  * \reimp
   206  * \reimp
   141  *
   207  *
   142  */
   208  */
   143 void RadioMainView::setOrientation()
   209 void RadioMainView::setOrientation()
   144 {
   210 {
   145     loadSection( DOCML::FILE_MAINVIEW, mMainWindow->orientationSection() );
   211     loadSection( DOCML::FILE_MAINVIEW, mMainWindow->orientationSection() );
       
   212     if ( mCarousel && mFrequencyStrip ) {
       
   213         mCarousel->setFrequency( mFrequencyStrip->frequency(), TuneReason::Unspecified );
       
   214     }
   146 }
   215 }
   147 
   216 
   148 /*!
   217 /*!
   149  * \reimp
   218  * \reimp
   150  *
   219  *
   151  */
   220  */
   152 void RadioMainView::userAccepted()
   221 void RadioMainView::userAccepted()
   153 {
   222 {
   154     mFrequencyScanner.reset( new RadioFrequencyScanner( mMainWindow->uiEngine(), this ) );
   223     mFrequencyScanner.reset( new RadioFrequencyScanner( *mUiEngine, this ) );
   155     mFrequencyScanner->startScanning();
   224     mFrequencyScanner->startScanning();
   156 }
   225 }
   157 
   226 
   158 /*!
   227 /*!
   159  * Private slot
   228  * \reimp
   160  */
   229  *
   161 void RadioMainView::setFrequencyFromWidget( uint frequency, int reason )
   230  */
   162 {
   231 bool RadioMainView::eventFilter( QObject* watched, QEvent* event )
   163     LOG_FORMAT( "RadioMainView::setFrequencyFromWidget: %u, reason = %d", frequency, reason );
   232 {
   164     if ( !RadioUiUtilities::isScannerAlive() ) {
   233     if ( event->type() == QEvent::ApplicationDeactivate ) {
       
   234         mFrequencyStrip->cancelManualSeek();
       
   235     }
       
   236 
       
   237     return RadioViewBase::eventFilter( watched, event );
       
   238 }
       
   239 
       
   240 /*!
       
   241  * Private slot
       
   242  */
       
   243 void RadioMainView::setFrequencyFromWidget( uint frequency, int reason, int direction )
       
   244 {
       
   245 //    LOG_FORMAT( "RadioMainView::setFrequencyFromWidget: %u, reason = %d", frequency, reason );
       
   246     if ( !RadioUtil::isScannerAlive() ) {
   165         if ( reason == TuneReason::FrequencyStrip ) {
   247         if ( reason == TuneReason::FrequencyStrip ) {
   166             mCarousel->setFrequency( frequency, reason );
   248 //            mCarousel->setFrequency( frequency, reason, direction );
   167             mMainWindow->uiEngine().tuneWithDelay( frequency, reason );
   249 //            mUiEngine->tuneWithDelay( frequency, reason );
       
   250         } else if ( reason == TuneReason::ManualSeekUpdate ) {
       
   251             mCarousel->setFrequency( frequency, reason, RadioUtil::scrollDirection( direction ) );
       
   252         } else if ( reason == TuneReason::ManualSeekTune ) {
       
   253             LOG_FORMAT( "--------Manual seek tune: %u", frequency );
       
   254             mUiEngine->setFrequency( frequency, reason );
   168         } else if ( reason == TuneReason::StationCarousel ) {
   255         } else if ( reason == TuneReason::StationCarousel ) {
   169             mFrequencyStrip->setFrequency( frequency, reason );
   256             mFrequencyStrip->setFrequency( frequency, reason, RadioUtil::scrollDirection( direction ) );
   170             mMainWindow->uiEngine().tuneFrequency( frequency, reason );
   257             mUiEngine->setFrequency( frequency, reason );
   171         }
   258         }
   172     }
   259     }
   173 }
   260 }
   174 
   261 
   175 /*!
   262 /*!
   176  * Private slot
   263  * Private slot
   177  */
   264  */
   178 void RadioMainView::setFrequencyFromEngine( uint frequency, int reason )
   265 void RadioMainView::setFrequencyFromEngine( uint frequency, int reason )
   179 {
   266 {
   180     if ( !RadioUiUtilities::isScannerAlive() ) {
   267     LOG_FORMAT( "RadioMainView::setFrequencyFromEngine reason: %d", reason );
       
   268     if ( RadioUtil::scanStatus() != Scan::ScanningInMainView && !mFrequencyStrip->isInManualSeekMode() ) {
   181         mCarousel->clearInfoText();
   269         mCarousel->clearInfoText();
       
   270         updateFavoriteButton();
   182         if ( reason != TuneReason::FrequencyStrip &&
   271         if ( reason != TuneReason::FrequencyStrip &&
   183              reason != TuneReason::StationCarousel &&
   272              reason != TuneReason::StationCarousel &&
   184              reason != TuneReason::Skip ) {
   273              reason != TuneReason::Skip ) {
   185             mCarousel->setFrequency( frequency, reason );
   274             mCarousel->setFrequency( frequency, reason, Scroll::Shortest );
   186             mFrequencyStrip->setFrequency( frequency, reason );
   275             mFrequencyStrip->setFrequency( frequency, reason, Scroll::Shortest );
   187         }
   276         }
   188     }
   277     }
   189 }
   278 }
   190 
   279 
   191 /*!
   280 /*!
   192  * Private slot
   281  * Private slot
   193  */
   282  */
   194 void RadioMainView::skip( int skipMode )
   283 void RadioMainView::skip( int skipMode )
   195 {
   284 {
   196     if ( ( skipMode == StationSkip::PreviousFavorite || skipMode == StationSkip::NextFavorite ) &&
   285 //    if ( !mAlternateSkipping && ( skipMode == StationSkip::PreviousFavorite || skipMode == StationSkip::NextFavorite ) &&
   197         mMainWindow->uiEngine().stationModel().favoriteCount() == 0 ) {
   286 //        mUiEngine->stationModel().favoriteCount() == 0 ) {
   198         mCarousel->setInfoText( CarouselInfoText::NoFavorites );
   287 //        mCarousel->setInfoText( CarouselInfoText::NoFavorites );
   199     } else {
   288 //    } else {
   200         const uint currentFrequency = mFrequencyStrip->frequency();
   289         const uint currentFrequency = mFrequencyStrip->frequency();
   201         const uint frequency = mMainWindow->uiEngine().skipStation( static_cast<StationSkip::Mode>( skipMode ),
   290         RadioStation station;
   202                                                                     currentFrequency);
   291         mUiEngine->stationModel().findFrequency( currentFrequency, station );
   203         mCarousel->setFrequency( frequency, TuneReason::Skip );
   292 
   204         mFrequencyStrip->setFrequency( frequency, TuneReason::Skip );
   293         if ( mAlternateSkipping ) { //TODO: Remove. Temporary test code
   205     }
   294             if ( sender() == mFrequencyStrip ) {
       
   295                 if ( skipMode == StationSkip::NextFavorite ) {
       
   296                     skipMode = StationSkip::Next;
       
   297                 } else if ( skipMode == StationSkip::PreviousFavorite ) {
       
   298                     skipMode = StationSkip::Previous;
       
   299                 }
       
   300             } else if ( sender() == mCarousel ) {
       
   301                 if ( skipMode == StationSkip::Next ) {
       
   302                     skipMode = StationSkip::NextFavorite;
       
   303                 } else if ( skipMode == StationSkip::Previous ) {
       
   304                     skipMode = StationSkip::PreviousFavorite;
       
   305                 }
       
   306             }
       
   307         }
       
   308 
       
   309         const uint frequency = mUiEngine->skipStation( static_cast<StationSkip::Mode>( skipMode ),
       
   310                                                                 currentFrequency);
       
   311 
       
   312         if ( currentFrequency != frequency || station.isFavorite() ) {
       
   313             const Scroll::Direction direction = RadioUtil::scrollDirectionFromSkipMode( skipMode );
       
   314             mCarousel->setFrequency( frequency, TuneReason::Skip, direction );
       
   315             mFrequencyStrip->setFrequency( frequency, TuneReason::Skip, direction );
       
   316         }
       
   317 //    }
       
   318 }
       
   319 
       
   320 /*!
       
   321  * Private slot
       
   322  */
       
   323 void RadioMainView::openStationsView()
       
   324 {
       
   325     mFrequencyStrip->cancelManualSeek();
       
   326     mMainWindow->activateStationsView();
   206 }
   327 }
   207 
   328 
   208 /*!
   329 /*!
   209  * Private slot
   330  * Private slot
   210  */
   331  */
   211 void RadioMainView::toggleScanning()
   332 void RadioMainView::toggleScanning()
   212 {
   333 {
       
   334     mFrequencyStrip->cancelManualSeek();
   213     if ( mFrequencyScanner ) {
   335     if ( mFrequencyScanner ) {
   214         mFrequencyScanner->cancelScanning();
   336         mFrequencyScanner->cancelScanning();
   215     } else {
   337     } else {
   216         const int rowCount =  mMainWindow->uiEngine().stationModel().rowCount();
   338         const int rowCount =  mUiEngine->stationModel().rowCount();
   217         if ( rowCount > 0 ) {
   339         if ( rowCount > 0 ) {
   218             askQuestion( hbTrId( "txt_rad_info_all_stations_in_stations_list_will_be" ) );
   340             askQuestion( hbTrId( "txt_rad_info_all_stations_in_stations_list_will_be" ) );
   219         } else {
   341         } else {
   220             userAccepted();
   342             userAccepted();
   221         }
   343         }
   223 }
   345 }
   224 
   346 
   225 /*!
   347 /*!
   226  * Private slot
   348  * Private slot
   227  */
   349  */
       
   350 void RadioMainView::toggleFavorite()
       
   351 {
       
   352     if ( RadioUtil::isScannerAlive() ) {
       
   353         toggleScanning();
       
   354     } else {
       
   355         mUiEngine->stationModel().setData( QModelIndex(), mFrequencyStrip->frequency(), RadioRole::ToggleFavoriteRole );
       
   356     }
       
   357 }
       
   358 
       
   359 /*!
       
   360  * Private slot
       
   361  */
   228 void RadioMainView::seekingStarted()
   362 void RadioMainView::seekingStarted()
   229 {
   363 {
   230     if ( !RadioUiUtilities::isScannerAlive() ) {
   364     if ( !RadioUtil::isScannerAlive() ) {
   231         mCarousel->setInfoText( CarouselInfoText::Seeking );
   365         mCarousel->setInfoText( CarouselInfoText::Seeking );
   232     }
   366     }
       
   367 }
       
   368 
       
   369 /*!
       
   370  * Private slot
       
   371  */
       
   372 void RadioMainView::updateAntennaStatus( bool connected )
       
   373 {
       
   374     if ( !connected ) {
       
   375         mFrequencyStrip->cancelManualSeek();
       
   376     }
       
   377 
       
   378     HbAction* scanAction = mUiLoader->findObject<HbAction>( DOCML::MV_NAME_SCAN_ACTION );
       
   379     scanAction->setEnabled( connected );
       
   380     mCarousel->updateAntennaStatus( connected );
   233 }
   381 }
   234 
   382 
   235 /*!
   383 /*!
   236  * Private slot
   384  * Private slot
   237  */
   385  */
   238 void RadioMainView::updateAudioRoute( bool loudspeaker )
   386 void RadioMainView::updateAudioRoute( bool loudspeaker )
   239 {
   387 {
   240     HbPushButton* loudspeakerButton = mUiLoader->findWidget<HbPushButton>( DOCML::MV_NAME_SPEAKER_BUTTON );
   388     HbPushButton* loudspeakerButton = mUiLoader->findWidget<HbPushButton>( DOCML::MV_NAME_SPEAKER_BUTTON );
   241     if ( loudspeaker ) {
   389     if ( loudspeaker ) {
   242         loudspeakerButton->setIcon( HbIcon( "qtg_mono_speaker_off.svg" ) );
   390         loudspeakerButton->setIcon( HbIcon( "qtg_mono_speaker_off" ) );
   243         loudspeakerButton->setText( hbTrId( "txt_rad_button_deactivate_loudspeaker" ) );
   391         loudspeakerButton->setText( hbTrId( "txt_rad_button_deactivate_loudspeaker" ) );
   244     } else {
   392     } else {
   245         loudspeakerButton->setIcon( HbIcon( "qtg_mono_speaker.svg" ) );
   393         loudspeakerButton->setIcon( HbIcon( "qtg_mono_speaker" ) );
   246         loudspeakerButton->setText( hbTrId( "txt_rad_button_activate_loudspeaker" ) );
   394         loudspeakerButton->setText( hbTrId( "txt_rad_button_activate_loudspeaker" ) );
   247     }
   395     }
   248 }
   396 }
       
   397 
       
   398 /*!
       
   399  * Private slot
       
   400  */
       
   401 void RadioMainView::setManualSeekMode( bool manualSeekActive )
       
   402 {
       
   403     if ( manualSeekActive ) {
       
   404         qApp->installEventFilter( this );
       
   405 
       
   406         mUiLoader->findWidget<HbPushButton>( DOCML::MV_NAME_FAVORITE_BUTTON )->setText( hbTrId( "txt_rad_button_add_to_favourites" ) );
       
   407     } else {
       
   408         qApp->removeEventFilter( this );
       
   409 
       
   410         updateFavoriteButton();
       
   411     }
       
   412 
       
   413     mUiEngine->setManualSeekMode( manualSeekActive );
       
   414 
       
   415     mCarousel->setManualSeekMode( manualSeekActive );
       
   416 }
       
   417 
       
   418 /*!
       
   419  * Private slot
       
   420  */
       
   421 void RadioMainView::handleFavoriteChange( const RadioStation& station )
       
   422 {
       
   423     mFrequencyStrip->updateFavorite( station );
       
   424     updateFavoriteButton();
       
   425 }
       
   426 
       
   427 /*!
       
   428  * Private slot
       
   429  */
       
   430 void RadioMainView::saveActivity()
       
   431 {
       
   432     HbActivityManager* activityManager = qobject_cast<HbApplication*>(qApp)->activityManager();
       
   433 
       
   434     // Get a screenshot for saving to the activity manager
       
   435     QSize screenShotSize = mCarousel->size().toSize();
       
   436     QPixmap screenShot( screenShotSize );
       
   437     QPainter painter( &screenShot );
       
   438 
       
   439     // Draw the background and overlay
       
   440     HbLabel* backgroundLabel = mUiLoader->findWidget<HbLabel>( DOCML::MV_NAME_CAROUSEL_BACKGROUND );
       
   441     painter.drawPixmap( 0, 0, backgroundLabel->icon().pixmap().scaled( screenShotSize ) );
       
   442     backgroundLabel = mUiLoader->findWidget<HbLabel>( DOCML::MV_NAME_CAROUSEL_OVERLAY );
       
   443     painter.drawPixmap( 0, 0, backgroundLabel->icon().pixmap().scaled( screenShotSize ) );
       
   444 
       
   445     mCarousel->drawOffScreen( painter );
       
   446 
       
   447     QVariantHash metadata;
       
   448     metadata.insert( "screenshot", screenShot );
       
   449 
       
   450     #ifdef __WINS__
       
   451         screenShot.save( "c:\\radio.bmp" );
       
   452     #elif defined BUILD_WIN32
       
   453         screenShot.save( "radio.bmp" );
       
   454     #endif
       
   455 
       
   456     // Update the activity to the activity manager
       
   457     bool ok = activityManager->removeActivity( RADIO_MAINVIEW_ACTIVITY_ID );
       
   458     LOG_ASSERT( ok, LOG( "Failed to remove old activity from Activity Manager!" ) );
       
   459     ok = activityManager->addActivity( RADIO_MAINVIEW_ACTIVITY_ID, QVariant(), metadata );
       
   460     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 }
       
   488 
       
   489 /*!
       
   490  *
       
   491  */
       
   492 void RadioMainView::updateFavoriteButton()
       
   493 {
       
   494     RadioStation station;
       
   495     RadioStationModel& model = mUiEngine->stationModel();
       
   496     model.findFrequency( mUiEngine->currentFrequency(), station );
       
   497     HbPushButton* favoriteButton = mUiLoader->findWidget<HbPushButton>( DOCML::MV_NAME_FAVORITE_BUTTON );
       
   498     if ( station.isFavorite() ) {
       
   499         favoriteButton->setText( hbTrId( "txt_fmradio_button_remove_from_favourites" ) );
       
   500         favoriteButton->setIcon( HbIcon( "qtg_mono_favourites_remove" ) );
       
   501     } else {
       
   502         favoriteButton->setText( hbTrId( "txt_rad_button_add_to_favourites" ) );
       
   503         favoriteButton->setIcon( HbIcon( "qtg_mono_add_to_favourites" ) );
       
   504     }
       
   505 }