qtinternetradio/ui/src/irapplication.cpp
changeset 8 3b03c28289e6
parent 5 0930554dc389
child 11 f683e24efca3
equal deleted inserted replaced
5:0930554dc389 8:3b03c28289e6
    24 #include <QFile>
    24 #include <QFile>
    25 #include <QTextStream>
    25 #include <QTextStream>
    26 #include <QDir>
    26 #include <QDir>
    27 #include <xqsharablefile.h> 
    27 #include <xqsharablefile.h> 
    28 #include <xqserviceutil.h>
    28 #include <xqserviceutil.h>
       
    29 #include <hbiconitem.h>
       
    30 #include <hbiconanimator.h>
       
    31 #include <hbiconanimationmanager.h>
    29 
    32 
    30 #ifdef LOCALIZATION 
    33 #ifdef LOCALIZATION 
    31 #include <QTranslator>
    34 #include <QTranslator>
    32 #include "irqutility.h" 
    35 #include "irqutility.h" 
    33 #endif
    36 #endif
    77                                      iLoadingNote(NULL),
    80                                      iLoadingNote(NULL),
    78                                      #ifdef LOCALIZATION
    81                                      #ifdef LOCALIZATION
    79                                      iTranslator(NULL),
    82                                      iTranslator(NULL),
    80                                      #endif
    83                                      #endif
    81                                      iSystemEventHandler(aSystemEventHandler),
    84                                      iSystemEventHandler(aSystemEventHandler),
    82                                      iPlayList(NULL)
    85                                      iPlayList(NULL),
       
    86                                      iLoadingAnimation(NULL)
    83                                      
    87                                      
    84 {
    88 {
    85     LOG_METHOD;
    89     LOG_METHOD;
    86     if (XQServiceUtil::isService())
    90     if (XQServiceUtil::isService())
    87     {
    91     {
   189     }
   193     }
   190     
   194     
   191     return ret;
   195     return ret;
   192 }
   196 }
   193 
   197 
   194 void IRApplication::createLoadingDialog(const QObject *aReceiver, const char *aFunc)
   198 void IRApplication::startLoadingAnimation(const QPointF& aPos)
       
   199 {
       
   200     if( NULL == iLoadingAnimation )
       
   201     {
       
   202         getLoadingAnimation();
       
   203     }
       
   204     
       
   205     if (iLoadingAnimation)
       
   206     {
       
   207         iLoadingAnimation->setPos(aPos);
       
   208         iLoadingAnimation->show();
       
   209         iLoadingAnimation->animator().startAnimation();
       
   210     }    
       
   211 }
       
   212 
       
   213 void IRApplication::startLoadingAnimation(const QObject *aReceiver, const char *aFunc)
   195 {
   214 {
   196     LOG_METHOD_ENTER;
   215     LOG_METHOD_ENTER;
   197     
   216     
   198     //for downloading logos in stations view, favorites view and history view, network connection
   217     //for downloading logos in stations view, favorites view and history view, network connection
   199     //is initiated by low layer, we don't show any dialog
   218     //is initiated by low layer, we don't show any dialog
   202         IRBaseView *currentView = static_cast<IRBaseView*>(iViewManager->currentView());
   221         IRBaseView *currentView = static_cast<IRBaseView*>(iViewManager->currentView());
   203         if (currentView && EIR_UseNetwork_NoReason == currentView->getUseNetworkReason())
   222         if (currentView && EIR_UseNetwork_NoReason == currentView->getUseNetworkReason())
   204         {
   223         {
   205             return;
   224             return;
   206         }
   225         }
       
   226     }
       
   227     
       
   228     //if in search, we could not show the dialog
       
   229     TIRViewId curViewID = static_cast<IRBaseView*>(iViewManager->currentView())->id();
       
   230     if ( EIRView_SearchView == curViewID )
       
   231     {
       
   232         return;        
   207     }
   233     }
   208     
   234     
   209     if (NULL == iLoadingNote)
   235     if (NULL == iLoadingNote)
   210     {
   236     {
   211         iLoadingNote = new HbProgressDialog(HbProgressDialog::WaitDialog);
   237         iLoadingNote = new HbProgressDialog(HbProgressDialog::WaitDialog);
   235     }
   261     }
   236     
   262     
   237     iLoadingNote->show();
   263     iLoadingNote->show();
   238 }
   264 }
   239 
   265 
   240 void IRApplication::closeLoadingDialog()
   266 void IRApplication::stopLoadingAnimation()
   241 {
   267 {
   242     LOG_METHOD_ENTER;
   268     LOG_METHOD_ENTER;
   243     if (iLoadingNote)
   269     if (iLoadingNote)
   244     {
   270     {
   245         iLoadingNote->close();
   271         iLoadingNote->close();
       
   272     }
       
   273     
       
   274     if( iLoadingAnimation )
       
   275     {
       
   276         iLoadingAnimation->animator().stopAnimation();
       
   277         iLoadingAnimation->hide();         
   246     }
   278     }
   247 }
   279 }
   248 
   280 
   249 /*
   281 /*
   250  * Description : return the pointer to the view manager object
   282  * Description : return the pointer to the view manager object
   450     if (iConnectingCanceled)
   482     if (iConnectingCanceled)
   451     {
   483     {
   452         return;
   484         return;
   453     }
   485     }
   454     
   486     
   455     closeLoadingDialog();
   487     stopLoadingAnimation();
   456     iConnectingCanceled = true;
   488     iConnectingCanceled = true;
   457     if (iNetworkController->getNetworkStatus())
   489     if (iNetworkController->getNetworkStatus())
   458     {
   490     {
   459         getIsdsClient()->isdsCancelRequest();
   491         getIsdsClient()->isdsCancelRequest();
   460     }
   492     }
   472 {
   504 {
   473     LOG_SLOT_CALLER;
   505     LOG_SLOT_CALLER;
   474     switch (aEvent)
   506     switch (aEvent)
   475     {
   507     {
   476         case EIRQNetworkConnectionConnecting :
   508         case EIRQNetworkConnectionConnecting :
   477             createLoadingDialog(this, SLOT(cancelConnect()));
   509             startLoadingAnimation(this, SLOT(cancelConnect()));
   478             iConnectingCanceled = false;
   510             iConnectingCanceled = false;
   479             break;
   511             break;
   480             
   512             
   481         case EIRQNetworkConnectionEstablished :
   513         case EIRQNetworkConnectionEstablished :
   482             iDisconnected = false;
   514             iDisconnected = false;
   505             }
   537             }
   506             break;
   538             break;
   507             
   539             
   508         case EIRQDisplayNetworkMessageNoConnectivity:
   540         case EIRQDisplayNetworkMessageNoConnectivity:
   509             {
   541             {
   510                 closeLoadingDialog();
   542                 stopLoadingAnimation();
   511                 HbMessageBox::warning(hbTrId("txt_irad_info_no_network_connectiion"), (QObject*)NULL, NULL);
   543                 HbMessageBox::warning(hbTrId("txt_irad_info_no_network_connectiion"), (QObject*)NULL, NULL);
   512                 if (!iDisconnected)
   544                 if (!iDisconnected)
   513                 {
   545                 {
   514                     /* the handling is up to each view */
   546                     /* the handling is up to each view */
   515                     iNetworkController->notifyActiveNetworkObservers(EIRQDisplayNetworkMessageNoConnectivity);
   547                     iNetworkController->notifyActiveNetworkObservers(EIRQDisplayNetworkMessageNoConnectivity);
   554     delete socket;
   586     delete socket;
   555     
   587     
   556     iViewManager->raise();
   588     iViewManager->raise();
   557 }
   589 }
   558 
   590 
       
   591 void IRApplication::getLoadingAnimation()
       
   592 {
       
   593     HbIconAnimationManager::global()->addDefinitionFile("qtg_anim_loading.axml");
       
   594     iLoadingAnimation = new HbIconItem("qtg_anim_loading");
       
   595     iLoadingAnimation->hide();
       
   596     QGraphicsScene *targetScene = getViewManager()->scene();
       
   597     QGraphicsScene *oldScene = iLoadingAnimation->scene();
       
   598 
       
   599     if (targetScene != oldScene)
       
   600     {
       
   601         if (oldScene)
       
   602         {
       
   603             oldScene->removeItem(iLoadingAnimation);
       
   604         }
       
   605         targetScene->addItem(iLoadingAnimation); // takes ownership
       
   606     }
       
   607 
       
   608 }
       
   609 
   559 void IRApplication::initApp()
   610 void IRApplication::initApp()
   560 {
   611 {
   561     getNetworkController();
   612     getNetworkController();    
       
   613     
   562     connect(iNetworkController, SIGNAL(networkEventNotified(IRQNetworkEvent)),
   614     connect(iNetworkController, SIGNAL(networkEventNotified(IRQNetworkEvent)),
   563             this, SLOT(networkEventNotified(IRQNetworkEvent)));
   615             this, SLOT(networkEventNotified(IRQNetworkEvent)));
   564     
   616     
   565     IRBaseView *view = static_cast<IRBaseView*> (iViewManager->currentView());
   617     IRBaseView *view = static_cast<IRBaseView*> (iViewManager->currentView());
   566     if (view)
   618     if (view)
   677 {
   729 {
   678     bool eventWasConsumed = false;
   730     bool eventWasConsumed = false;
   679 
   731 
   680     if (object->objectName() == ABSTRACT_LIST_VIEW_BASE_OBJECT_PLAYINGBANNER)
   732     if (object->objectName() == ABSTRACT_LIST_VIEW_BASE_OBJECT_PLAYINGBANNER)
   681     {
   733     {
       
   734         if (NULL == iViewManager->currentView())
       
   735         {
       
   736             return false;
       
   737         }
       
   738         
   682         if( (EIRView_PlayingView == static_cast<IRBaseView*>(iViewManager->currentView())->id()) \
   739         if( (EIRView_PlayingView == static_cast<IRBaseView*>(iViewManager->currentView())->id()) \
   683         	||(EIRView_SearchView == static_cast<IRBaseView*>(iViewManager->currentView())->id()) )
   740         	||(EIRView_SearchView == static_cast<IRBaseView*>(iViewManager->currentView())->id()) )
   684         {
   741         {
   685             return false;
   742             return false;
   686         }    
   743         }    
   729     //for the buffering state needs more attention, we firstly
   786     //for the buffering state needs more attention, we firstly
   730     //don't handle it, improve in future.
   787     //don't handle it, improve in future.
   731     if( iPlayController->isPlaying() /*|| iPlayController->isBuffering()*/)
   788     if( iPlayController->isPlaying() /*|| iPlayController->isBuffering()*/)
   732     {
   789     {
   733         iPlayController->stop(EIRQCallIsActivated);
   790         iPlayController->stop(EIRQCallIsActivated);
   734         closeLoadingDialog();
   791         stopLoadingAnimation();
   735     }
   792     }
   736 	
   793 	
   737 	//for we don't cancel the loading when call is activated, 
   794 	//for we don't cancel the loading when call is activated, 
   738 	//so, here , we don't add the handling for it. 
   795 	//so, here , we don't add the handling for it. 
   739 }
   796 }