--- a/radioapp/radiowidgets/src/radiomainview.cpp Fri Jun 11 13:38:32 2010 +0300
+++ b/radioapp/radiowidgets/src/radiomainview.cpp Wed Jun 23 18:12:57 2010 +0300
@@ -17,7 +17,6 @@
// System includes
#include <QTimer>
-#include <HbLabel>
#include <HbPushButton>
#include <HbAction>
#include <HbMenu>
@@ -66,6 +65,7 @@
loadSection( DOCML::FILE_MAINVIEW, DOCML::MV_SECTION_SCANNING );
} else {
loadSection( DOCML::FILE_MAINVIEW, DOCML::MV_SECTION_NORMAL );
+ updateFavoriteButton();
mFrequencyScanner.take();
const bool firsTimeStart = mUiEngine->isFirstTimeStart();
@@ -87,7 +87,6 @@
mCarousel = mUiLoader->findObject<RadioStationCarousel>( DOCML::MV_NAME_STATION_CAROUSEL );
mCarousel->init( *mUiLoader, mUiEngine.data() );
- // Note! UI connections are already made in the DocML file. Here we need to connect UI to engine
mFrequencyStrip = mUiLoader->findObject<RadioFrequencyStrip>( DOCML::MV_NAME_FREQUENCY_STRIP );
mFrequencyStrip->init( mUiEngine.data(), *mUiLoader );
@@ -122,12 +121,17 @@
connectXmlElement( DOCML::MV_NAME_STATIONS_BUTTON, SIGNAL(clicked()),
mMainWindow, SLOT(activateStationsView()) );
- connectXmlElement( DOCML::MV_NAME_SCAN_BUTTON, SIGNAL(clicked()),
- this, SLOT(toggleScanning()) );
+ connectXmlElement( DOCML::MV_NAME_FAVORITE_BUTTON, SIGNAL(clicked()),
+ this, SLOT(toggleFavorite()) );
connectXmlElement( DOCML::MV_NAME_SPEAKER_BUTTON, SIGNAL(clicked()),
mUiEngine.data(), SLOT(toggleAudioRoute()) );
+ connectXmlElement( DOCML::MV_NAME_SCAN_ACTION, SIGNAL(triggered()),
+ this, SLOT(toggleScanning()) );
+
+ updateFavoriteButton();
+
connectCommonMenuItem( MenuItem::Exit );
// "Play history" menu item
@@ -135,7 +139,7 @@
//TODO: REMOVE. THIS IS TEMPORARY TEST CODE
toggleSkippingMode();
- menu()->addAction( "Reset start count", this, SLOT(resetFirstTimeCount()) );
+ menu()->addAction( "-- Reset start count", this, SLOT(resetFirstTimeCount()) );
// END TEMPORARY TEST CODE
updateAudioRoute( mUiEngine->isUsingLoudspeaker() );
@@ -223,8 +227,9 @@
void RadioMainView::setFrequencyFromEngine( uint frequency, int reason )
{
LOG_FORMAT( "RadioMainView::setFrequencyFromEngine reason: %d", reason );
- if ( !RadioUtil::isScannerAlive() && !mFrequencyStrip->isInManualSeekMode() ) {
+ if ( RadioUtil::scanStatus() != Scan::ScanningInMainView && !mFrequencyStrip->isInManualSeekMode() ) {
mCarousel->clearInfoText();
+ updateFavoriteButton();
if ( reason != TuneReason::FrequencyStrip &&
reason != TuneReason::StationCarousel &&
reason != TuneReason::Skip ) {
@@ -304,6 +309,18 @@
/*!
* Private slot
*/
+void RadioMainView::toggleFavorite()
+{
+ if ( RadioUtil::isScannerAlive() ) {
+ toggleScanning();
+ } else {
+ mUiEngine->stationModel().setData( QModelIndex(), mFrequencyStrip->frequency(), RadioRole::ToggleFavoriteRole );
+ }
+}
+
+/*!
+ * Private slot
+ */
void RadioMainView::seekingStarted()
{
if ( !RadioUtil::isScannerAlive() ) {
@@ -320,8 +337,8 @@
mFrequencyStrip->cancelManualSeek();
}
- HbPushButton* scanButton = mUiLoader->findWidget<HbPushButton>( DOCML::MV_NAME_SCAN_BUTTON );
- scanButton->setEnabled( connected );
+ HbAction* scanAction = mUiLoader->findObject<HbAction>( DOCML::MV_NAME_SCAN_ACTION );
+ scanAction->setEnabled( connected );
mCarousel->updateAntennaStatus( connected );
}
@@ -347,8 +364,12 @@
{
if ( manualSeekActive ) {
qApp->installEventFilter( this );
+
+ mUiLoader->findWidget<HbPushButton>( DOCML::MV_NAME_FAVORITE_BUTTON )->setText( hbTrId( "txt_rad_button_add_to_favourites" ) );
} else {
qApp->removeEventFilter( this );
+
+ updateFavoriteButton();
}
mUiEngine->setManualSeekMode( manualSeekActive );
@@ -362,11 +383,7 @@
void RadioMainView::handleFavoriteChange( const RadioStation& station )
{
mFrequencyStrip->updateFavorite( station );
- if ( station.isFavorite() ) {
- RadioUtil::showDiscreetNote( "Station added to Favourites." );
- } else {
- RadioUtil::showDiscreetNote( "Station removed from Favourites." );
- }
+ updateFavoriteButton();
}
/*!
@@ -381,9 +398,9 @@
mAlternateSkipping = !mAlternateSkipping;
mCarousel->setAlternateSkippingMode( mAlternateSkipping );
if ( mAlternateSkipping ) {
- mSkippingAction->setText( "Normal skipping mode" );
+ mSkippingAction->setText( "-- Normal skipping mode" );
} else {
- mSkippingAction->setText( "Alternate skipping mode" );
+ mSkippingAction->setText( "-- Alternate skipping mode" );
}
}
@@ -394,3 +411,22 @@
{
mUiEngine->setFirstTimeStartPerformed( false );
}
+
+/*!
+ *
+ */
+void RadioMainView::updateFavoriteButton()
+{
+ RadioStation station;
+ RadioStationModel& model = mUiEngine->stationModel();
+ model.findFrequency( mUiEngine->currentFrequency(), station );
+ HbPushButton* favoriteButton = mUiLoader->findWidget<HbPushButton>( DOCML::MV_NAME_FAVORITE_BUTTON );
+ if ( station.isFavorite() ) {
+ //TODO: Get localized text
+ favoriteButton->setText( "Remove from favourites" );
+// favoriteButton->setIcon( HbIcon( ":/images/pri_small_star_inactive.svg" ) );
+ } else {
+ favoriteButton->setText( hbTrId( "txt_rad_button_add_to_favourites" ) );
+// favoriteButton->setIcon( HbIcon( ":/images/pri_small_star.svg" ) );
+ }
+}