mmsharing/livecommsui/lcui/src/lcuicomponentrepository.cpp
changeset 26 5554410e16f5
parent 25 53c1c4459a94
child 29 36d7ded3ca23
equal deleted inserted replaced
25:53c1c4459a94 26:5554410e16f5
    30 #include <hbmessagebox.h>
    30 #include <hbmessagebox.h>
    31 #include <hbdialog.h>
    31 #include <hbdialog.h>
    32 #include <hbprogressdialog.h>
    32 #include <hbprogressdialog.h>
    33 #include <hblabel.h>
    33 #include <hblabel.h>
    34 #include <hbinstance.h>
    34 #include <hbinstance.h>
    35 #include <hbzoomsliderpopup.h>
       
    36 #include <hbdialog.h>
    35 #include <hbdialog.h>
    37 #include <hbpushbutton.h>
    36 #include <hbpushbutton.h>
    38 #include <hbframedrawer.h>
    37 #include <hbframedrawer.h>
    39 #include <hbstyleloader.h>
    38 #include <hbstyleloader.h>
    40 #include <dialpad.h>
    39 #include <dialpad.h>
    55       mReceiveOnlyView(0),
    54       mReceiveOnlyView(0),
    56       mAcceptQuery(0),
    55       mAcceptQuery(0),
    57       mInvitingNote(0),
    56       mInvitingNote(0),
    58       mWaitingNote(0),
    57       mWaitingNote(0),
    59       mRecipientQuery(0),
    58       mRecipientQuery(0),
    60       mZoomSlider(0),
       
    61       mShareOwnVideoQuery(0)
    59       mShareOwnVideoQuery(0)
    62 {
    60 {
    63     LC_QDEBUG( "livecomms [UI] -> LcUiComponentRepository::LcUiComponentRepository()" )
    61     LC_QDEBUG( "livecomms [UI] -> LcUiComponentRepository::LcUiComponentRepository()" )
    64     
    62     
    65     mSlots = new QHash<QString,const char*>;
    63     mSlots = new QHash<QString,const char*>;
    73     mSlots->insert( lcActGalleryId, SLOT( notSupported() ) );
    71     mSlots->insert( lcActGalleryId, SLOT( notSupported() ) );
    74     mSlots->insert( lcActChangeCameraId, SLOT( notSupported() ) );    
    72     mSlots->insert( lcActChangeCameraId, SLOT( notSupported() ) );    
    75     mSlots->insert( lcActAdjustVideoId, SLOT( notSupported() ) );
    73     mSlots->insert( lcActAdjustVideoId, SLOT( notSupported() ) );
    76     mSlots->insert( lcActShareImageId, SLOT( notSupported() ) );
    74     mSlots->insert( lcActShareImageId, SLOT( notSupported() ) );
    77     mSlots->insert( lcActSwapViewsId, SLOT( swap() ) );
    75     mSlots->insert( lcActSwapViewsId, SLOT( swap() ) );
    78     mSlots->insert( lcActZoomId, SLOT( notSupported() ) );
       
    79     mSlots->insert( lcActSwitchToVoiceCallId, SLOT( switchToVoiceCall() ) );    
    76     mSlots->insert( lcActSwitchToVoiceCallId, SLOT( switchToVoiceCall() ) );    
    80     mSlots->insert( lcActOpenKeypadId, SLOT( openDialpad() ) );
    77     mSlots->insert( lcActOpenKeypadId, SLOT( openDialpad() ) );
    81     mSlots->insert( lcActDisableCameraId, SLOT( disableCamera() ) );
    78     mSlots->insert( lcActDisableCameraId, SLOT( disableCamera() ) );
    82     mSlots->insert( lcActSpeakerId, SLOT( speaker() ) );
    79     mSlots->insert( lcActSpeakerId, SLOT( speaker() ) );
    83 
    80 
   106     
   103     
   107     delete mAcceptQuery;
   104     delete mAcceptQuery;
   108     delete mInvitingNote;
   105     delete mInvitingNote;
   109     delete mWaitingNote;
   106     delete mWaitingNote;
   110     delete mRecipientQuery;
   107     delete mRecipientQuery;
   111     delete mZoomSlider;
       
   112     delete mShareOwnVideoQuery;
   108     delete mShareOwnVideoQuery;
   113  
   109  
   114     LC_QDEBUG( "livecomms [UI] <- LcUiComponentRepository::~LcUiComponentRepository()" )
   110     LC_QDEBUG( "livecomms [UI] <- LcUiComponentRepository::~LcUiComponentRepository()" )
   115 }
   111 }
   116 
   112 
   388 {
   384 {
   389     LC_QDEBUG( "livecomms [UI] -> LcUiComponentRepository::shareOwnVideoQuery()" );
   385     LC_QDEBUG( "livecomms [UI] -> LcUiComponentRepository::shareOwnVideoQuery()" );
   390 
   386 
   391     if ( !mShareOwnVideoQuery ) {
   387     if ( !mShareOwnVideoQuery ) {
   392         mShareOwnVideoQuery = new HbMessageBox( HbMessageBox::MessageTypeQuestion );
   388         mShareOwnVideoQuery = new HbMessageBox( HbMessageBox::MessageTypeQuestion );
       
   389         mShareOwnVideoQuery->setStandardButtons( HbMessageBox::Yes | HbMessageBox::No );
   393         mShareOwnVideoQuery->setText( hbTrId( "txt_vt_info_allow_own_image_to_be_sent" ));
   390         mShareOwnVideoQuery->setText( hbTrId( "txt_vt_info_allow_own_image_to_be_sent" ));
   394         mShareOwnVideoQuery->setZValue(LC_NOTE_ON_TOP);
   391         mShareOwnVideoQuery->setZValue(LC_NOTE_ON_TOP);
   395         mShareOwnVideoQuery->setTimeout( HbDialog::NoTimeout );
   392         mShareOwnVideoQuery->setTimeout( HbDialog::NoTimeout );
   396         mShareOwnVideoQuery->setDismissPolicy( HbDialog::NoDismiss );        
   393         mShareOwnVideoQuery->setDismissPolicy( HbDialog::NoDismiss );        
   397         mShareOwnVideoQuery->setVisible(false);
   394         mShareOwnVideoQuery->setVisible(false);
   399     LC_QDEBUG( "livecomms [UI] <- LcUiComponentRepository::shareOwnVideoQuery()" );
   396     LC_QDEBUG( "livecomms [UI] <- LcUiComponentRepository::shareOwnVideoQuery()" );
   400     return mShareOwnVideoQuery;
   397     return mShareOwnVideoQuery;
   401 }
   398 }
   402 
   399 
   403 // -----------------------------------------------------------------------------
   400 // -----------------------------------------------------------------------------
   404 // LcUiComponentRepository::zoomSlider
       
   405 // -----------------------------------------------------------------------------
       
   406 //
       
   407 HbZoomSliderPopup* LcUiComponentRepository::zoomSlider()
       
   408 {
       
   409     LC_QDEBUG( "livecomms [UI] -> LcUiComponentRepository::zoomSlider()" );
       
   410     
       
   411     if ( !mZoomSlider ) {
       
   412         mZoomSlider = new HbZoomSliderPopup();
       
   413         mZoomSlider->setDismissPolicy(HbDialog::TapOutside);
       
   414         mZoomSlider->setTimeout(HbDialog::StandardTimeout);
       
   415         mZoomSlider->hide();
       
   416         QObject::connect( mZoomSlider, SIGNAL(valueChanged(int)), 
       
   417                           &mEngine, SLOT(zoom(int)) );
       
   418         
       
   419     }
       
   420     
       
   421     LC_QDEBUG( "livecomms [UI] <- LcUiComponentRepository::zoomSlider()" );
       
   422     return mZoomSlider;
       
   423 }
       
   424 
       
   425 // -----------------------------------------------------------------------------
       
   426 // LcUiComponentRepository::sharedVideoContextMenuActions
   401 // LcUiComponentRepository::sharedVideoContextMenuActions
   427 // -----------------------------------------------------------------------------
   402 // -----------------------------------------------------------------------------
   428 //
   403 //
   429 void LcUiComponentRepository::sharedVideoContextMenuActions( HbMenu* menu, LcView& view )
   404 void LcUiComponentRepository::sharedVideoContextMenuActions( HbMenu* menu, LcView& view )
   430 {
   405 {
   434     
   409     
   435     menu->actions().clear();
   410     menu->actions().clear();
   436     //due stubs in unit tests, qobject_cast cannot be used. 
   411     //due stubs in unit tests, qobject_cast cannot be used. 
   437     //Using static_cast instead
   412     //Using static_cast instead
   438     HbAction* swap = static_cast<HbAction*>( findObject( lcActSwapViewsId ) );
   413     HbAction* swap = static_cast<HbAction*>( findObject( lcActSwapViewsId ) );
   439     HbAction* zoom = static_cast<HbAction*>( findObject( lcActZoomId ) );
   414     HbAction* changeCamera = 
       
   415         static_cast<HbAction*>( findObject( lcActMenuChangeCameraId ) );
       
   416     
       
   417     HbAction* disableCamera = 
       
   418         static_cast<HbAction*>( findObject( lcActMenuDisableCameraId ) );
       
   419     HbAction* enableCamera = 
       
   420             static_cast<HbAction*>( findObject( lcActEnableCameraId ) );
       
   421               
       
   422     if ( swap ) {
       
   423         LC_QDEBUG_2( "Adding ", swap->text() );
       
   424         menu->addAction( swap );
       
   425     }
       
   426     if ( changeCamera ) {
       
   427         LC_QDEBUG_2( "Adding ", changeCamera->text() );
       
   428         menu->addAction( changeCamera );
       
   429     }
       
   430     if ( mEngine.isLocalPlayerPlaying() ) {
       
   431         if ( disableCamera ) {
       
   432             LC_QDEBUG_2( "Adding ", disableCamera->text() );
       
   433             menu->addAction( disableCamera );
       
   434         }    
       
   435     } else {
       
   436         if ( enableCamera ) {
       
   437             LC_QDEBUG_2( "Adding ", enableCamera->text() );
       
   438             menu->addAction( enableCamera );
       
   439         }        
       
   440     }
       
   441 
       
   442   
       
   443     LC_QDEBUG( 
       
   444    "livecomms [UI] <- LcUiComponentRepository::sharedVideoContextMenuActions()" );
       
   445 }
       
   446 
       
   447 // -----------------------------------------------------------------------------
       
   448 // LcUiComponentRepository::loadView
       
   449 // -----------------------------------------------------------------------------
       
   450 //
       
   451 LcView* LcUiComponentRepository::loadView( QObjectList& components,
       
   452                                            const QString& viewId, 
       
   453                                            const QString& xmlFile )
       
   454 {
       
   455     LC_QDEBUG( "livecomms [UI] -> LcUiComponentRepository::loadView()" );
       
   456 
       
   457     LcView* view = 0;
       
   458     bool ok( false );
       
   459     // Load the XML file
       
   460     components = load( xmlFile, &ok );
       
   461 
       
   462     if ( !ok ) {
       
   463         LC_QCRITICAL_3( "! loading of XML file ", xmlFile , " failed !" )
       
   464         return 0;
       
   465     }
       
   466     
       
   467     mLastLoadedView = xmlFile;
       
   468 
       
   469     ok = loadLayout( lcLayoutLandscapeDefaultId );
       
   470     if ( !ok ) {
       
   471          LC_QCRITICAL( "! loading of layout failed !" )
       
   472          return 0;
       
   473      }
       
   474 
       
   475     view = qobject_cast<LcView*>( findWidget( viewId ) );
       
   476     if ( view ) {
       
   477         connectActions( *view );
       
   478         view->init();
       
   479     }
       
   480     
       
   481     LC_QDEBUG( "livecomms [UI] <- LcUiComponentRepository::loadView()" );
       
   482     return view;
       
   483 }
       
   484 
       
   485     
       
   486 // -----------------------------------------------------------------------------
       
   487 // LcUiComponentRepository::connectActions
       
   488 // -----------------------------------------------------------------------------
       
   489 //
       
   490 void LcUiComponentRepository::connectActions( LcView& view ) const
       
   491 {
       
   492     LC_QDEBUG( "livecomms [UI] -> LcUiComponentRepository::connectActions()" );
       
   493     foreach( QAction* hbAction, view.menu()->actions() ) {
       
   494         connect( *hbAction, view );
       
   495     }
       
   496     foreach( QAction* hbAction, view.toolBar()->actions() ) {
       
   497         connect( *hbAction, view );
       
   498     }
       
   499 
   440     HbAction* changeCamera = 
   500     HbAction* changeCamera = 
   441         static_cast<HbAction*>( findObject( lcActMenuChangeCameraId ) );
   501         static_cast<HbAction*>( findObject( lcActMenuChangeCameraId ) );
   442     HbAction* disableCamera = 
   502     HbAction* disableCamera = 
   443         static_cast<HbAction*>( findObject( lcActMenuDisableCameraId ) );
   503         static_cast<HbAction*>( findObject( lcActMenuDisableCameraId ) );
   444               
   504     HbAction* enableCamera = 
   445     if ( swap ) {
   505         static_cast<HbAction*>( findObject( lcActEnableCameraId ) );
   446         LC_QDEBUG_2( "Adding ", swap->text() );
       
   447         menu->addAction( swap );
       
   448     }
       
   449     if ( zoom ) {
       
   450         LC_QDEBUG_2( "Adding ", zoom->text() );
       
   451         menu->addAction( zoom );
       
   452     }
       
   453     if ( changeCamera ) {
       
   454         LC_QDEBUG_2( "Adding ", changeCamera->text() );
       
   455         menu->addAction( changeCamera );
       
   456     }
       
   457     if ( disableCamera ) {
       
   458         LC_QDEBUG_2( "Adding ", disableCamera->text() );
       
   459         menu->addAction( disableCamera );
       
   460     }
       
   461 
       
   462   
       
   463     LC_QDEBUG( 
       
   464    "livecomms [UI] <- LcUiComponentRepository::sharedVideoContextMenuActions()" );
       
   465 }
       
   466 
       
   467 // -----------------------------------------------------------------------------
       
   468 // LcUiComponentRepository::loadView
       
   469 // -----------------------------------------------------------------------------
       
   470 //
       
   471 LcView* LcUiComponentRepository::loadView( QObjectList& components,
       
   472                                            const QString& viewId, 
       
   473                                            const QString& xmlFile )
       
   474 {
       
   475     LC_QDEBUG( "livecomms [UI] -> LcUiComponentRepository::loadView()" );
       
   476     
       
   477     LcView* view = 0;
       
   478     bool ok( false );
       
   479     // Load the XML file
       
   480     components = load( xmlFile, &ok );
       
   481 
       
   482     if ( !ok ) {
       
   483         LC_QCRITICAL_3( "! loading of XML file ", xmlFile , " failed !" )
       
   484         return 0;    		
       
   485     }
       
   486     mLastLoadedView = xmlFile;
       
   487 
       
   488     // Load default layout for the current device orientation    
       
   489     if ( !HbInstance::instance()->allMainWindows().isEmpty() && 
       
   490          HbInstance::instance()->allMainWindows().at(0)->orientation() == Qt::Horizontal ) {  
       
   491         ok = loadLayout( lcLayoutLandscapeDefaultId );
       
   492         
       
   493     } else {
       
   494         ok = loadLayout( lcLayoutPortraitDefaultId );
       
   495     }        
       
   496     if ( !ok ) {
       
   497          LC_QCRITICAL( "! loading of layout failed !" )
       
   498          return 0;           
       
   499      }      
       
   500 
       
   501     view = qobject_cast<LcView*>( findWidget( viewId ) );
       
   502     if ( view ) {
       
   503     	connectActions( *view );
       
   504     	view->init(); 
       
   505     } 
       
   506     
       
   507     LC_QDEBUG( "livecomms [UI] <- LcUiComponentRepository::loadView()" );
       
   508     return view;
       
   509 }
       
   510     
       
   511 // -----------------------------------------------------------------------------
       
   512 // LcUiComponentRepository::connectActions
       
   513 // -----------------------------------------------------------------------------
       
   514 //
       
   515 void LcUiComponentRepository::connectActions( LcView& view ) const
       
   516 {
       
   517     LC_QDEBUG( "livecomms [UI] -> LcUiComponentRepository::connectActions()" );
       
   518     foreach( QAction* hbAction, view.menu()->actions() ) {
       
   519         connect( *hbAction, view );
       
   520     }
       
   521     foreach( QAction* hbAction, view.toolBar()->actions() ) {
       
   522         connect( *hbAction, view );
       
   523     }
       
   524 
       
   525     HbAction* changeCamera = 
       
   526         static_cast<HbAction*>( findObject( lcActMenuChangeCameraId ) );
       
   527     HbAction* disableCamera = 
       
   528         static_cast<HbAction*>( findObject( lcActMenuDisableCameraId ) );
       
   529 
   506 
   530     QObject::connect( changeCamera, SIGNAL(triggered()), 
   507     QObject::connect( changeCamera, SIGNAL(triggered()), 
   531       &view, SLOT(notSupported()) );
   508       &view, SLOT(notSupported()) );
   532 
   509 
   533     QObject::connect( disableCamera, SIGNAL(triggered()), 
   510     QObject::connect( disableCamera, SIGNAL(triggered()), 
   534       &view, SLOT(disableCamera()) );
   511       &view, SLOT(disableCamera()) );
       
   512     
       
   513     QObject::connect( enableCamera, SIGNAL(triggered()), 
       
   514           &view, SLOT(disableCamera()) );
   535     
   515     
   536     LC_QDEBUG( "livecomms [UI] <- LcUiComponentRepository::connectActions()" )  
   516     LC_QDEBUG( "livecomms [UI] <- LcUiComponentRepository::connectActions()" )  
   537 }
   517 }
   538 
   518 
   539 // -----------------------------------------------------------------------------
   519 // -----------------------------------------------------------------------------
   575             LC_QCRITICAL( "! loading of XML failed !" )
   555             LC_QCRITICAL( "! loading of XML failed !" )
   576         }
   556         }
   577         else{
   557         else{
   578             mPreviousLayout = mLayout; 
   558             mPreviousLayout = mLayout; 
   579             mLayout = layoutName;
   559             mLayout = layoutName;
   580             setObjectTree( objects );
       
   581         }
   560         }
   582     } else {
   561     } else {
   583         LC_QCRITICAL( "! not loading layout, since view is not loaded!" )
   562         LC_QCRITICAL( "! not loading layout, since view is not loaded!" )
   584     }
   563     }
   585 
   564