mmsharing/livecommsui/lcui/src/lcuicomponentrepository.cpp
branchRCL_3
changeset 33 bc78a40cd63c
parent 32 73a1feb507fb
child 35 6c57ef9392d2
equal deleted inserted replaced
32:73a1feb507fb 33:bc78a40cd63c
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 *
       
    16 */
       
    17 
       
    18 //USER
       
    19 #include "lcuicomponentrepository.h"
       
    20 #include "lcview.h"
       
    21 #include "lcuidefs.h"
       
    22 #include "lclogger.h"
       
    23 #include "lcuiengine.h"
       
    24 #include "lcvideowidget.h"
       
    25 
       
    26 //SYSTEM
       
    27 #include <hbaction.h>
       
    28 #include <hbmenu.h>
       
    29 #include <hbtoolbar.h>
       
    30 #include <hbmessagebox.h>
       
    31 #include <hbdialog.h>
       
    32 #include <hbprogressdialog.h>
       
    33 #include <hblabel.h>
       
    34 #include <hbinstance.h>
       
    35 #include <hbdialog.h>
       
    36 #include <hbpushbutton.h>
       
    37 #include <hbframedrawer.h>
       
    38 #include <hbstyleloader.h>
       
    39 #include <dialpad.h>
       
    40 
       
    41 // -----------------------------------------------------------------------------
       
    42 // LcUiComponentRepository::LcUiComponentRepository
       
    43 // -----------------------------------------------------------------------------
       
    44 //
       
    45 LcUiComponentRepository::LcUiComponentRepository(LcUiEngine& engine)
       
    46     : HbDocumentLoader(),
       
    47       mEngine(engine),
       
    48       mSlots(0),
       
    49       mIdleView(0),
       
    50       mReceiveView(0),
       
    51       mSendView(0),
       
    52       mTwowayView(0),
       
    53       mAllInOneView(0),
       
    54       mReceiveOnlyView(0),
       
    55       mAcceptQuery(0),
       
    56       mInvitingNote(0),
       
    57       mWaitingNote(0),
       
    58       mRecipientQuery(0),
       
    59       mShareOwnVideoQuery(0)
       
    60 {
       
    61     LC_QDEBUG( "livecomms [UI] -> LcUiComponentRepository::LcUiComponentRepository()" )
       
    62     
       
    63     mSlots = new QHash<QString,const char*>;
       
    64     mSlots->insert( lcActFullscreenId, SLOT( notSupported() ) );
       
    65     mSlots->insert( lcActVideopreferenceId, SLOT( notSupported() ) );
       
    66     mSlots->insert( lcActDialerId, SLOT( notSupported() ) );
       
    67     mSlots->insert( lcActEndactivecallId, SLOT( notSupported() ) );
       
    68     mSlots->insert( lcActStopSharingId, SLOT( endVideoSession() ) );
       
    69     mSlots->insert( lcActEnableCameraId, SLOT( disableCamera() ) );
       
    70     mSlots->insert( lcActMuteId, SLOT( mute() ) );
       
    71     mSlots->insert( lcActGalleryId, SLOT( notSupported() ) );
       
    72     mSlots->insert( lcActChangeCameraId, SLOT( changeCamera() ) );    
       
    73     mSlots->insert( lcActAdjustVideoId, SLOT( notSupported() ) );
       
    74     mSlots->insert( lcActShareImageId, SLOT( notSupported() ) );
       
    75     mSlots->insert( lcActSwapViewsId, SLOT( swap() ) );
       
    76     mSlots->insert( lcActSwitchToVoiceCallId, SLOT( switchToVoiceCall() ) );    
       
    77     mSlots->insert( lcActOpenKeypadId, SLOT( openDialpad() ) );
       
    78     mSlots->insert( lcActDisableCameraId, SLOT( disableCamera() ) );
       
    79     mSlots->insert( lcActSpeakerId, SLOT( speaker() ) );
       
    80 
       
    81     mSlots->insert( lcActMenuDisableCameraId, SLOT( disableCamera() ) );    
       
    82     mSlots->insert( lcActMenuChangeCameraId, SLOT( changeCamera() ) );    
       
    83     
       
    84     LC_QDEBUG( "livecomms [UI] <- LcUiComponentRepository::LcUiComponentRepository()" )
       
    85 }
       
    86 
       
    87 // -----------------------------------------------------------------------------
       
    88 // LcUiComponentRepository::~LcUiComponentRepository
       
    89 // -----------------------------------------------------------------------------
       
    90 //
       
    91 LcUiComponentRepository::~LcUiComponentRepository()
       
    92 {
       
    93     LC_QDEBUG( "livecomms [UI] -> LcUiComponentRepository::~LcUiComponentRepository()" )
       
    94     
       
    95     delete mSlots;
       
    96     
       
    97     mIdleViewComponents.clear();
       
    98     mReceiveViewComponents.clear();
       
    99     mSendViewComponents.clear();
       
   100     mTwowayViewComponents.clear();
       
   101     mAllInOneViewComponents.clear();
       
   102     mReceiveOnlyViewComponents.clear();
       
   103     
       
   104     delete mAcceptQuery;
       
   105     delete mInvitingNote;
       
   106     delete mWaitingNote;
       
   107     delete mRecipientQuery;
       
   108     delete mShareOwnVideoQuery;
       
   109  
       
   110     LC_QDEBUG( "livecomms [UI] <- LcUiComponentRepository::~LcUiComponentRepository()" )
       
   111 }
       
   112 
       
   113 // -----------------------------------------------------------------------------
       
   114 // LcUiComponentRepository::createObject
       
   115 // -----------------------------------------------------------------------------
       
   116 //
       
   117 QObject* LcUiComponentRepository::createObject(
       
   118         const QString& type, const QString &name)
       
   119 {
       
   120     QObject* object = 0;
       
   121     
       
   122     if ( type == lcLcViewTypeName || 
       
   123          name == lcViewIdleId ||
       
   124          name == lcViewReceiveId || 
       
   125          name == lcViewReceiveOnlyId || 
       
   126          name == lcViewAllInOneId || 
       
   127          name == lcViewSendId ||
       
   128          name == lcViewTwowayId ) {
       
   129         LC_QDEBUG_2( "-> LcUiComponentRepository::createObject() ",
       
   130         "- creating LcView -" )
       
   131         object = new LcView( mEngine, *this );           
       
   132     } 
       
   133     else if ( name == lcWidgetSendVideoId ) {
       
   134         LC_QDEBUG_2( "-> LcUiComponentRepository::createObject() ",
       
   135         "- creating shared video widget -" )
       
   136         object = new LcVideoWidget();
       
   137         static_cast<LcVideoWidget*>(object)->setLocalPlayer(true);
       
   138     }
       
   139     else if ( name == lcWidgetSendVideoId2 ) {
       
   140         LC_QDEBUG_2( "-> LcUiComponentRepository::createObject() ",
       
   141         "- creating shared video widget effect overlay -" )
       
   142         object = new LcVideoWidget(0, false);
       
   143         static_cast<LcVideoWidget*>(object)->setLocalPlayer(true);
       
   144     }
       
   145     else if ( name == lcWidgetRecvVideoId ) {
       
   146         LC_QDEBUG_2( "-> LcUiComponentRepository::createObject() ",
       
   147         "- creating received video widget -" )
       
   148         object = new LcVideoWidget();
       
   149         static_cast<LcVideoWidget*>(object)->setLocalPlayer(false);
       
   150                 
       
   151     }  
       
   152     else if ( name == lcWidgetRecvVideoId2 ) {
       
   153         LC_QDEBUG_2( "-> LcUiComponentRepository::createObject() ",
       
   154         "- creating received video widget effect overlay -" )
       
   155         object = new LcVideoWidget(0, false);
       
   156         static_cast<LcVideoWidget*>(object)->setLocalPlayer(false);
       
   157     }
       
   158     else if ( name == lcButtonEndCall ){
       
   159         object = HbDocumentLoader::createObject( type, name );
       
   160         HbFrameDrawer*frameDrawer = new HbFrameDrawer("qtg_fr_btn_red_normal",HbFrameDrawer::NinePieces);
       
   161         static_cast<HbPushButton*>(object)->setFrameBackground(frameDrawer);
       
   162         HbStyleLoader::registerFilePath(":/hbpushbutton_color.css");
       
   163     }
       
   164     else if ( name == lcWidgetDialpad ){
       
   165       HbMainWindow* pWindow = HbInstance::instance()->allMainWindows().at(0);
       
   166         if( pWindow ){
       
   167             object = new Dialpad( *pWindow );
       
   168         }
       
   169     }
       
   170     else {
       
   171         object = HbDocumentLoader::createObject( type, name );
       
   172     }
       
   173     if (object) {
       
   174         object->setObjectName(name);
       
   175     }
       
   176     
       
   177     LC_QDEBUG_2( "livecomms [UI] <- LcUiComponentRepository::createObject(), name=", name )
       
   178     
       
   179     return object;
       
   180 }
       
   181 
       
   182 // -----------------------------------------------------------------------------
       
   183 // LcUiComponentRepository::idleView
       
   184 // -----------------------------------------------------------------------------
       
   185 //
       
   186 LcView* LcUiComponentRepository::idleView()
       
   187 {
       
   188     LC_QDEBUG( "livecomms [UI] -> LcUiComponentRepository::idleView()" );
       
   189 
       
   190     reset();
       
   191     setObjectTree( mIdleViewComponents );
       
   192     
       
   193     if ( !mIdleView ) {
       
   194         mIdleView = loadView( 
       
   195             mIdleViewComponents, lcViewIdleId, lcIdleViewFile );
       
   196     }
       
   197     LC_QDEBUG( "livecomms [UI] <- LcUiComponentRepository::idleView()" );
       
   198     return mIdleView;
       
   199 }
       
   200 
       
   201 // -----------------------------------------------------------------------------
       
   202 // LcUiComponentRepository::receiveView
       
   203 // -----------------------------------------------------------------------------
       
   204 //
       
   205 LcView* LcUiComponentRepository::receiveView()
       
   206 {
       
   207     LC_QDEBUG( "livecomms [UI] -> LcUiComponentRepository::receiveView()" );
       
   208 
       
   209     reset();
       
   210     setObjectTree( mReceiveViewComponents );
       
   211     if ( !mReceiveView ) {
       
   212         mReceiveView = loadView( 
       
   213             mReceiveViewComponents, lcViewReceiveId, lcReceiveViewFile );
       
   214     } 
       
   215     LC_QDEBUG( "livecomms [UI] <- LcUiComponentRepository::receiveView()" );
       
   216     return mReceiveView;
       
   217 }
       
   218 
       
   219 // -----------------------------------------------------------------------------
       
   220 // LcUiComponentRepository::receiveOnlyView
       
   221 // -----------------------------------------------------------------------------
       
   222 //
       
   223 LcView* LcUiComponentRepository::receiveOnlyView()
       
   224 {
       
   225     LC_QDEBUG( "livecomms [UI] -> LcUiComponentRepository::receiveOnlyView()" );
       
   226 
       
   227     reset();
       
   228     setObjectTree( mReceiveOnlyViewComponents );
       
   229     if ( !mReceiveOnlyView ) {
       
   230         mReceiveOnlyView = loadView( 
       
   231             mReceiveOnlyViewComponents, lcViewReceiveOnlyId, lcReceiveOnlyViewFile );
       
   232     } 
       
   233     LC_QDEBUG( "livecomms [UI] <- LcUiComponentRepository::receiveOnlyView()" );
       
   234     return mReceiveOnlyView;
       
   235 }
       
   236 
       
   237 // -----------------------------------------------------------------------------
       
   238 // LcUiComponentRepository::twowayView
       
   239 // -----------------------------------------------------------------------------
       
   240 //
       
   241 LcView* LcUiComponentRepository::twowayView()
       
   242 {
       
   243     LC_QDEBUG( "livecomms [UI] -> LcUiComponentRepository::twowayView()" );
       
   244 
       
   245     reset();
       
   246     setObjectTree( mTwowayViewComponents );
       
   247     if ( !mTwowayView ) {
       
   248         mTwowayView = loadView( 
       
   249             mTwowayViewComponents, lcViewTwowayId, lcTwowayViewFile );
       
   250     } 
       
   251     LC_QDEBUG( "livecomms [UI] <- LcUiComponentRepository::twowayView()" );
       
   252     return mTwowayView; 
       
   253 }
       
   254 
       
   255 // -----------------------------------------------------------------------------
       
   256 // LcUiComponentRepository::sendView
       
   257 // -----------------------------------------------------------------------------
       
   258 //
       
   259 LcView* LcUiComponentRepository::sendView()
       
   260 {
       
   261     LC_QDEBUG( "livecomms [UI] -> LcUiComponentRepository::sendView()" );
       
   262 
       
   263     reset();
       
   264     setObjectTree( mSendViewComponents );
       
   265     if ( !mSendView ) {
       
   266         mSendView = 
       
   267             loadView( mSendViewComponents, lcViewSendId, lcSendViewFile );
       
   268     } 
       
   269     LC_QDEBUG( "livecomms [UI] <- LcUiComponentRepository::sendView()" );
       
   270     return mSendView; 
       
   271 }
       
   272 
       
   273 // -----------------------------------------------------------------------------
       
   274 // LcUiComponentRepository::allInOneView
       
   275 // -----------------------------------------------------------------------------
       
   276 //
       
   277 LcView* LcUiComponentRepository::allInOneView()
       
   278 {
       
   279     LC_QDEBUG( "livecomms [UI] -> LcUiComponentRepository::allInOneView()" );
       
   280 
       
   281     reset();
       
   282     setObjectTree( mAllInOneViewComponents );
       
   283     if ( !mAllInOneView ) {
       
   284         mAllInOneView = loadView( 
       
   285             mAllInOneViewComponents, lcViewAllInOneId, lcAllInOneViewFile );
       
   286     }
       
   287     LC_QDEBUG( "livecomms [UI] <- LcUiComponentRepository::allInOneView()" );
       
   288     return mAllInOneView;   
       
   289 }
       
   290 
       
   291 // -----------------------------------------------------------------------------
       
   292 // LcUiComponentRepository::acceptQuery
       
   293 // -----------------------------------------------------------------------------
       
   294 //
       
   295 HbDialog* LcUiComponentRepository::acceptQuery()
       
   296 {
       
   297     LC_QDEBUG( "livecomms [UI] -> LcUiComponentRepository::acceptQuery()" );
       
   298 
       
   299     if ( !mAcceptQuery ) {
       
   300         mAcceptQuery = new HbDialog();
       
   301         HbAction* acceptAction = new HbAction( LC_OK );
       
   302         HbAction* rejectAction = new HbAction( LC_CANCEL );
       
   303         mAcceptQuery->addAction(acceptAction);
       
   304         mAcceptQuery->addAction(rejectAction);
       
   305         mAcceptQuery->setVisible(false);
       
   306         HbLabel* label = new HbLabel( LC_ACCEPT_SESSION );
       
   307         mAcceptQuery->setHeadingWidget(label);
       
   308         HbLabel* label2 = new HbLabel();
       
   309         mAcceptQuery->setContentWidget(label2);
       
   310         mAcceptQuery->setTimeout(0);
       
   311         mAcceptQuery->setDismissPolicy(HbDialog::NoDismiss);
       
   312     }
       
   313     LC_QDEBUG( "livecomms [UI] <- LcUiComponentRepository::acceptQuery()" );
       
   314     return mAcceptQuery;
       
   315 }
       
   316 
       
   317 // -----------------------------------------------------------------------------
       
   318 // LcUiComponentRepository::invitingNote
       
   319 // -----------------------------------------------------------------------------
       
   320 //
       
   321 HbProgressDialog* LcUiComponentRepository::invitingNote()
       
   322 {
       
   323     LC_QDEBUG( "livecomms [UI] -> LcUiComponentRepository::invitingNote()" );
       
   324     
       
   325     if ( !mInvitingNote ) {
       
   326         mInvitingNote = new HbProgressDialog();
       
   327         mInvitingNote->setVisible(false);
       
   328         mInvitingNote->setText( LC_INVITING );
       
   329         HbAction* rejectAction = new HbAction( LC_CANCEL );
       
   330         mInvitingNote->addAction(rejectAction);
       
   331     } 
       
   332     LC_QDEBUG( "livecomms [UI] <- LcUiComponentRepository::invitingNote()" );
       
   333     return mInvitingNote;
       
   334 }
       
   335 
       
   336 // -----------------------------------------------------------------------------
       
   337 // LcUiComponentRepository::waitingNote
       
   338 // -----------------------------------------------------------------------------
       
   339 //
       
   340 HbProgressDialog* LcUiComponentRepository::waitingNote()
       
   341 {
       
   342     LC_QDEBUG( "livecomms [UI] -> LcUiComponentRepository::waitingNote()" );
       
   343     
       
   344     if ( !mWaitingNote ) {
       
   345         mWaitingNote = new HbProgressDialog();
       
   346         mWaitingNote->setVisible(false);
       
   347         HbAction* rejectAction = new HbAction( LC_CANCEL );
       
   348         mWaitingNote->addAction(rejectAction);   
       
   349         mWaitingNote->setText( LC_WAITING_VIDEO );
       
   350     }
       
   351     LC_QDEBUG( "livecomms [UI] <- LcUiComponentRepository::waitingNote()" );
       
   352     return mWaitingNote;
       
   353 }
       
   354 
       
   355 // -----------------------------------------------------------------------------
       
   356 // LcUiComponentRepository::recipientQuery
       
   357 // -----------------------------------------------------------------------------
       
   358 //
       
   359 HbDialog* LcUiComponentRepository::recipientQuery()
       
   360 {
       
   361     LC_QDEBUG( "livecomms [UI] -> LcUiComponentRepository::recipientQuery()" );
       
   362 
       
   363     if ( !mRecipientQuery ) {
       
   364         mRecipientQuery = new HbDialog();
       
   365         HbLabel* label = new HbLabel( LC_RECIPIENT_QUERY );
       
   366         mRecipientQuery->setHeadingWidget(label);
       
   367         mRecipientQuery->setTimeout(HbDialog::NoTimeout);
       
   368         mRecipientQuery->setDismissPolicy(HbDialog::TapOutside);
       
   369         HbAction* acceptAction = new HbAction( LC_OK );
       
   370         HbAction* rejectAction = new HbAction( LC_CANCEL );
       
   371         mRecipientQuery->addAction(acceptAction);
       
   372         mRecipientQuery->addAction(rejectAction);
       
   373         mRecipientQuery->setVisible(false);
       
   374     }
       
   375     LC_QDEBUG( "livecomms [UI] <- LcUiComponentRepository::recipientQuery()" );
       
   376     return mRecipientQuery;
       
   377 }
       
   378 
       
   379 // -----------------------------------------------------------------------------
       
   380 // LcUiComponentRepository::shareOwnVideoQuery
       
   381 // -----------------------------------------------------------------------------
       
   382 //
       
   383 HbDialog* LcUiComponentRepository::shareOwnVideoQuery()
       
   384 {
       
   385     LC_QDEBUG( "livecomms [UI] -> LcUiComponentRepository::shareOwnVideoQuery()" );
       
   386 
       
   387     if ( !mShareOwnVideoQuery ) {
       
   388         mShareOwnVideoQuery = new HbMessageBox( HbMessageBox::MessageTypeQuestion );
       
   389         mShareOwnVideoQuery->setStandardButtons( HbMessageBox::Yes | HbMessageBox::No );
       
   390         mShareOwnVideoQuery->setText( hbTrId( "txt_vt_info_allow_own_image_to_be_sent" ));
       
   391         mShareOwnVideoQuery->setZValue(LC_NOTE_ON_TOP);
       
   392         mShareOwnVideoQuery->setTimeout( HbDialog::NoTimeout );
       
   393         mShareOwnVideoQuery->setDismissPolicy( HbDialog::NoDismiss );        
       
   394         mShareOwnVideoQuery->setVisible(false);
       
   395     }
       
   396     LC_QDEBUG( "livecomms [UI] <- LcUiComponentRepository::shareOwnVideoQuery()" );
       
   397     return mShareOwnVideoQuery;
       
   398 }
       
   399 
       
   400 // -----------------------------------------------------------------------------
       
   401 // LcUiComponentRepository::sharedVideoContextMenuActions
       
   402 // -----------------------------------------------------------------------------
       
   403 //
       
   404 void LcUiComponentRepository::sharedVideoContextMenuActions( HbMenu* menu, LcView& view )
       
   405 {
       
   406     Q_UNUSED(view)
       
   407     LC_QDEBUG( 
       
   408    "livecomms [UI] -> LcUiComponentRepository::sharedVideoContextMenuActions()" );
       
   409     
       
   410     menu->actions().clear();
       
   411     //due stubs in unit tests, qobject_cast cannot be used. 
       
   412     //Using static_cast instead
       
   413     HbAction* swap = static_cast<HbAction*>( findObject( lcActSwapViewsId ) );
       
   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 
       
   500     HbAction* changeCamera = 
       
   501         static_cast<HbAction*>( findObject( lcActMenuChangeCameraId ) );
       
   502     HbAction* disableCamera = 
       
   503         static_cast<HbAction*>( findObject( lcActMenuDisableCameraId ) );
       
   504     HbAction* enableCamera = 
       
   505         static_cast<HbAction*>( findObject( lcActEnableCameraId ) );
       
   506 
       
   507     QObject::connect( changeCamera, SIGNAL(triggered()), 
       
   508       &view, SLOT(changeCamera()) );
       
   509 
       
   510     QObject::connect( disableCamera, SIGNAL(triggered()), 
       
   511       &view, SLOT(disableCamera()) );
       
   512     
       
   513     QObject::connect( enableCamera, SIGNAL(triggered()), 
       
   514           &view, SLOT(disableCamera()) );
       
   515     
       
   516     LC_QDEBUG( "livecomms [UI] <- LcUiComponentRepository::connectActions()" )  
       
   517 }
       
   518 
       
   519 // -----------------------------------------------------------------------------
       
   520 // LcUiComponentRepository::connect
       
   521 // -----------------------------------------------------------------------------
       
   522 //
       
   523 bool LcUiComponentRepository::connect( QAction& hbAction, LcView& view ) const
       
   524 {
       
   525     LC_QDEBUG_2( "livecomms [UI] -> LcUiComponentRepository::connect() action=",
       
   526                  hbAction.objectName() )
       
   527     
       
   528     const char* method = mSlots->value( hbAction.objectName() ); 
       
   529     bool slotFound = ( QString( method ).length() > 0 );
       
   530     
       
   531     if ( slotFound ) {
       
   532         QObject::connect( &hbAction, SIGNAL(triggered()), &view, method );  
       
   533     }
       
   534     
       
   535     LC_QDEBUG( "livecomms [UI] <- LcUiComponentRepository::connect()" )
       
   536     
       
   537     return slotFound;
       
   538 }
       
   539 
       
   540 
       
   541 // -----------------------------------------------------------------------------
       
   542 // LcUiComponentRepository::loadLayout
       
   543 // -----------------------------------------------------------------------------
       
   544 //
       
   545 bool LcUiComponentRepository::loadLayout( const QString& layoutName )
       
   546     {
       
   547     LC_QDEBUG( "livecomms [UI] -> LcUiComponentRepository::loadLayout()" )    
       
   548     bool ok( false );
       
   549   
       
   550     if ( mLastLoadedView.length() > 0) {
       
   551         LC_QDEBUG_4( "layout = ", layoutName, ", view =",  mLastLoadedView )
       
   552 
       
   553         load( mLastLoadedView, layoutName, &ok );
       
   554         if (!ok) {
       
   555             LC_QCRITICAL( "! loading of XML failed !" )
       
   556         }
       
   557         else{
       
   558             mPreviousLayout = mLayout; 
       
   559             mLayout = layoutName;
       
   560         }
       
   561     } else {
       
   562         LC_QCRITICAL( "! not loading layout, since view is not loaded!" )
       
   563     }
       
   564 
       
   565     LC_QDEBUG( "livecomms [UI] <- LcUiComponentRepository::loadLayout()" )
       
   566     return ok;
       
   567     }
       
   568 
       
   569 // -----------------------------------------------------------------------------
       
   570 // LcUiComponentRepository::layout()const
       
   571 // -----------------------------------------------------------------------------
       
   572 //
       
   573 QString LcUiComponentRepository::layout()const
       
   574     {
       
   575     LC_QDEBUG_2( "livecomms [UI] -> LcUiComponentRepository::layout()",mLayout )    
       
   576     return mLayout;
       
   577     }
       
   578 
       
   579 // -----------------------------------------------------------------------------
       
   580 // LcUiComponentRepository::previousLayout()const
       
   581 // -----------------------------------------------------------------------------
       
   582 //
       
   583 QString LcUiComponentRepository::previousLayout()const
       
   584     {
       
   585     LC_QDEBUG_2( "livecomms [UI] -> LcUiComponentRepository::previousLayout()",
       
   586                                                               mPreviousLayout )    
       
   587     return mPreviousLayout;
       
   588     }
       
   589 // End of file