app/src/mpglobalpopuphandler.cpp
changeset 48 af3740e3753f
parent 41 ea59c434026a
child 54 c5b304f4d89b
equal deleted inserted replaced
42:79c49924ae23 48:af3740e3753f
    63     mMpEngine = MpEngineFactory::sharedEngine();
    63     mMpEngine = MpEngineFactory::sharedEngine();
    64     connect( mMpEngine, SIGNAL( libraryAboutToUpdate() ), this, SLOT( handleLibraryAboutToUpdate() ) );
    64     connect( mMpEngine, SIGNAL( libraryAboutToUpdate() ), this, SLOT( handleLibraryAboutToUpdate() ) );
    65     connect( mMpEngine, SIGNAL( unableToCotinueDueUSB() ), this, SLOT( launchUnableToCotinueDueUsb() ) );
    65     connect( mMpEngine, SIGNAL( unableToCotinueDueUSB() ), this, SLOT( launchUnableToCotinueDueUsb() ) );
    66     connect( mMpEngine, SIGNAL( usbSynchronizationStarted() ), this, SLOT( launchUsbBlockingNote() ) );
    66     connect( mMpEngine, SIGNAL( usbSynchronizationStarted() ), this, SLOT( launchUsbBlockingNote() ) );
    67     connect( mMpEngine, SIGNAL( usbSynchronizationFinished() ), this, SLOT( closeUsbBlockingNote() ) );
    67     connect( mMpEngine, SIGNAL( usbSynchronizationFinished() ), this, SLOT( closeUsbBlockingNote() ) );
    68     connect( mMpEngine, SIGNAL( libraryRefreshNeeded() ), this, SLOT( launchRefreshLibraryRequest() ) );
       
    69     TX_EXIT
    68     TX_EXIT
    70 }
    69 }
    71 
    70 
    72 /*!
    71 /*!
    73  Destructs the collection popup handler.
    72  Destructs the collection popup handler.
   137 {
   136 {
   138     TX_ENTRY_ARGS("count " << count )
   137     TX_ENTRY_ARGS("count " << count )
   139     if ( mOutstandingPopup && ( mOutstandingPopup->objectName() == KScanProgressDialog ) ) {
   138     if ( mOutstandingPopup && ( mOutstandingPopup->objectName() == KScanProgressDialog ) ) {
   140         HbProgressDialog *dialog = qobject_cast<HbProgressDialog *>( mOutstandingPopup );
   139         HbProgressDialog *dialog = qobject_cast<HbProgressDialog *>( mOutstandingPopup );
   141         QString added;
   140         QString added;
   142         added = hbTrId( "txt_mus_info_ln_songs_added" , count );
   141         added = hbTrId( "txt_mus_info_ln_songs_found" , count );
   143         dialog->setText( added );
   142         dialog->setText( added );
   144     }
   143     }
   145     TX_EXIT
   144     TX_EXIT
   146 }
   145 }
   147 
   146 
   151  
   150  
   152  */
   151  */
   153 void MpGlobalPopupHandler::handleScanFinished( int error, int itemsAdded )
   152 void MpGlobalPopupHandler::handleScanFinished( int error, int itemsAdded )
   154 {
   153 {
   155     TX_ENTRY_ARGS("error: " << error << " Items added: " << itemsAdded )
   154     TX_ENTRY_ARGS("error: " << error << " Items added: " << itemsAdded )
       
   155 
   156     if ( mOutstandingPopup && ( mOutstandingPopup->objectName() == KScanProgressDialog ) ) {
   156     if ( mOutstandingPopup && ( mOutstandingPopup->objectName() == KScanProgressDialog ) ) {
   157         HbProgressDialog *dialog = qobject_cast<HbProgressDialog *>( mOutstandingPopup );
   157         HbProgressDialog *dialog = qobject_cast<HbProgressDialog *>( mOutstandingPopup );
   158         disconnect( dialog, SIGNAL( aboutToClose() ), this, SLOT( outstandingPopupClosing() ) );
   158         disconnect( dialog, SIGNAL( aboutToClose() ), this, SLOT( outstandingPopupClosing() ) );
   159         mOutstandingPopup = 0;
   159         mOutstandingPopup = 0;
   160         dialog->close();
   160         dialog->close();
   161     }
   161     }
   162 
   162 
   163     switch( error ) {
   163     switch( error ) {
   164         case MpSongScanner::ScanErrorNone :
   164         case MpSongScanner::ScanErrorNone :
   165             launchScanFinishedDialog( true, itemsAdded );
   165             launchScanFinishedDialog( true , itemsAdded );
   166             break;
   166             break;
   167         case MpSongScanner::ScanGeneralError :
   167         case MpSongScanner::ScanGeneralError :
   168             launchScanFinishedDialog( false, itemsAdded );
   168             launchScanFinishedDialog( false, itemsAdded );
   169             break;
   169             break;
   170         case MpSongScanner::ScanErrorDiskFull :
   170         case MpSongScanner::ScanErrorDiskFull :
   221         dialog->cancel();
   221         dialog->cancel();
   222     }
   222     }
   223 }
   223 }
   224 
   224 
   225 /*!
   225 /*!
   226  Slot called when MpEngine emits libraryRefreshNeeded() signal
       
   227  */
       
   228 void MpGlobalPopupHandler::launchRefreshLibraryRequest()
       
   229 {
       
   230     HbAction *action;
       
   231     HbMessageBox *promptRefresh = new HbMessageBox( HbMessageBox::MessageTypeQuestion );
       
   232     promptRefresh->setText( hbTrId( "txt_mus_info_music_may_need_to_be_refreshed" ) );
       
   233     promptRefresh->setTimeout( HbPopup::NoTimeout );
       
   234     promptRefresh->setModal( true );
       
   235     promptRefresh->clearActions();
       
   236     action = new HbAction( hbTrId( "txt_common_button_yes" ) );
       
   237     action->setObjectName( KYes );
       
   238     connect( action, SIGNAL( triggered() ), mMpEngine, SLOT( refreshLibrary() ) );
       
   239     promptRefresh->addAction( action );
       
   240     action = new HbAction( hbTrId( "txt_common_button_no" ) );
       
   241     action->setObjectName( KNo );
       
   242     promptRefresh->addAction( action );
       
   243     promptRefresh->setAttribute( Qt::WA_DeleteOnClose );
       
   244     promptRefresh->setObjectName( KPromptRefresh );
       
   245     setOutstandingPopup( promptRefresh );
       
   246     promptRefresh->show();
       
   247 }
       
   248 
       
   249 /*!
       
   250   Slot to launch the MTP educating info dialog
   226   Slot to launch the MTP educating info dialog
       
   227   This dialog would be displayed after any manual refresh (from options menu),
       
   228   or after a refreshing originated by USBMassStorage disconnection.
   251  */
   229  */
   252 void MpGlobalPopupHandler::launchMTPInfoDialog()
   230 void MpGlobalPopupHandler::launchMTPInfoDialog()
   253 {
   231 {
   254     TX_ENTRY
   232     TX_ENTRY
   255     HbDialog *dialog = new HbDialog();
   233     HbDialog *dialog = new HbDialog();
   300 
   278 
   301 /*!
   279 /*!
   302  \internal
   280  \internal
   303  Launches Scan Finished Notification.
   281  Launches Scan Finished Notification.
   304  */
   282  */
   305 void MpGlobalPopupHandler::launchScanFinishedDialog( bool ok, int itemsAdded )
   283 void MpGlobalPopupHandler::launchScanFinishedDialog( bool ok , int itemsAdded )
   306 {
   284 {
   307     QString added;
       
   308     HbNotificationDialog *finishedDialog = new HbNotificationDialog();
   285     HbNotificationDialog *finishedDialog = new HbNotificationDialog();
   309     finishedDialog->setModal(true);
   286     finishedDialog->setModal(true);
   310     added = hbTrId( "txt_mus_dpopinfo_ln_songs_added", itemsAdded );
       
   311     finishedDialog->setText( added );
       
   312     finishedDialog->setAttribute( Qt::WA_DeleteOnClose );
   287     finishedDialog->setAttribute( Qt::WA_DeleteOnClose );
   313     finishedDialog->setObjectName( KScanFinished );
   288     finishedDialog->setObjectName( KScanFinished );
   314     // Connect aboutToClose with outstandingPopupClosing() first, and then with launchMTPInfoDialog
   289     // Connect aboutToClose with outstandingPopupClosing() first, and then with launchMTPInfoDialog
   315     // in order to get finishDialog cleared before MtpInfoDialog is launched.
   290     // in order to get finishDialog cleared before MtpInfoDialog is launched.
   316     setOutstandingPopup( finishedDialog );
   291     setOutstandingPopup( finishedDialog );
   317 
   292 
       
   293     // Educating user (of MTP information) dialog is displayed
       
   294     // only when the following conditions are met:
       
   295     // 1. A "manual" refresh operation completes successfully
       
   296     // 2. Refresh operation finds at least one new item
       
   297 
   318     if( ok ) {
   298     if( ok ) {
   319         finishedDialog->setIcon( HbIcon( QString("qtg_large_ok") ) );
   299         finishedDialog->setIcon( HbIcon( QString("qtg_large_ok") ) );
   320         finishedDialog->setTitle( hbTrId( "txt_mus_dpophead_refresh_complete" ) );
   300         finishedDialog->setTitle( hbTrId( "txt_mus_dpophead_refresh_complete" ) );
   321         if ( MpSettingsManager::showMtpInfo() && !mMpSongScanner->isAutomaticScan() ) {
   301         if ( MpSettingsManager::showMtpInfo() && !mMpSongScanner->isAutomaticScan() && itemsAdded ) {
   322             connect( finishedDialog, SIGNAL( aboutToClose() ), this, SLOT( launchMTPInfoDialog() ) );
   302             connect( finishedDialog, SIGNAL( aboutToClose() ), this, SLOT( launchMTPInfoDialog() ) );
   323         }
   303         }
   324     }
   304     }
   325     else {
   305     else {
   326         finishedDialog->setIcon( HbIcon( QString("qtg_small_fail") ) );
   306         finishedDialog->setIcon( HbIcon( QString("qtg_small_fail") ) );