36 #include <QDebug> |
36 #include <QDebug> |
37 #include <hbstyleloader.h> |
37 #include <hbstyleloader.h> |
38 #include <hbprogressdialog.h> |
38 #include <hbprogressdialog.h> |
39 #include <QItemSelectionModel> |
39 #include <QItemSelectionModel> |
40 #include <glxmainwindoweventfilter.h> |
40 #include <glxmainwindoweventfilter.h> |
|
41 #include <xqsettingsmanager.h> |
|
42 #include <xqsettingskey.h> |
41 |
43 |
42 |
44 |
43 GlxViewManager::GlxViewManager() |
45 GlxViewManager::GlxViewManager() |
44 : mBackAction( NULL ), |
46 : mBackAction( NULL ), |
45 mMenuManager( NULL ), |
47 mMenuManager( NULL ), |
46 mEffectEngine( NULL ), |
48 mEffectEngine( NULL ), |
47 mViewToolBar( NULL ), |
49 mViewToolBar( NULL ), |
48 mMarkingToolBar( NULL ), |
50 mMarkingToolBar( NULL ), |
49 mMenu( NULL ), |
|
50 mSelectionModel ( NULL ), |
51 mSelectionModel ( NULL ), |
51 mProgressDialog( NULL ) |
52 mProgressDialog( NULL ) |
52 { |
53 { |
53 qDebug("GlxViewManager::GlxViewManager() "); |
54 qDebug("GlxViewManager::GlxViewManager() "); |
54 PERFORMANCE_ADV ( viewMgrD1, "main window creation time" ) { |
55 PERFORMANCE_ADV ( viewMgrD1, "main window creation time" ) { |
55 //check the case when application launch through some other application (view plugin) |
56 //check the case when application launch through some other application (view plugin) |
56 mMainWindow = GlxExternalUtility::instance()->getMainWindow(); |
57 mMainWindow = GlxExternalUtility::instance()->getMainWindow(); |
57 if(mMainWindow == NULL) { |
58 if(mMainWindow == NULL) { |
58 mMainWindow = new HbMainWindow(); |
59 mMainWindow = new HbMainWindow(); |
|
60 connect(mMainWindow, SIGNAL( viewReady() ), this, SLOT( handleReadyView() )); |
59 } |
61 } |
60 //Without this Zoom Does not work |
62 //Without this Zoom Does not work |
61 |
63 |
62 mWindowEventFilter = new GlxMainWindowEventFilter; |
64 mWindowEventFilter = new GlxMainWindowEventFilter; |
63 mMainWindow->scene()->installEventFilter(mWindowEventFilter); |
65 mMainWindow->scene()->installEventFilter(mWindowEventFilter); |
64 mMainWindow->viewport()->setAttribute(Qt::WA_AcceptTouchEvents); |
66 mMainWindow->viewport()->setAttribute(Qt::WA_AcceptTouchEvents); |
65 mMainWindow->viewport()->grabGesture(Qt::PinchGesture); |
67 mMainWindow->viewport()->grabGesture(Qt::PinchGesture); |
66 } |
68 } |
67 HbStyleLoader::registerFilePath(":/data/photos.css"); |
69 HbStyleLoader::registerFilePath(":/data/photos.css"); |
|
70 } |
|
71 void GlxViewManager::handleReadyView() |
|
72 { |
|
73 emit actionTriggered( EGlxCmdSetupItem ); |
|
74 emit applicationReady(); |
|
75 disconnect(mMainWindow, SIGNAL( viewReady() ), this, SLOT( handleReadyView() )); |
68 } |
76 } |
69 |
77 |
70 void GlxViewManager::setupItems( ) |
78 void GlxViewManager::setupItems( ) |
71 { |
79 { |
72 mMenuManager = new GlxMenuManager(mMainWindow); |
80 mMenuManager = new GlxMenuManager(mMainWindow); |
271 int max = mProgressDialog->maximum() ; |
283 int max = mProgressDialog->maximum() ; |
272 if ( currentValue > max ) { |
284 if ( currentValue > max ) { |
273 mProgressDialog->setMaximum( currentValue ); |
285 mProgressDialog->setMaximum( currentValue ); |
274 max = currentValue ; |
286 max = currentValue ; |
275 } |
287 } |
276 int value = max - currentValue; |
288 |
277 mProgressDialog->setProgressValue( value ); |
|
278 mProgressDialog->setIcon(icon); |
289 mProgressDialog->setIcon(icon); |
279 mProgressDialog->setText( QString( " %1 / %2").arg( value ).arg( max ) ); |
290 |
|
291 if ( currentValue < 0 ) { |
|
292 mProgressDialog->setText( QString( "Refreshing" ) ); //To:Do string will change later |
|
293 mProgressDialog->setProgressValue( 0 ); |
|
294 } |
|
295 else { |
|
296 int value = max - currentValue; |
|
297 mProgressDialog->setProgressValue( value ); |
|
298 mProgressDialog->setText( QString( " %1 " ).arg( currentValue ) ); |
|
299 } |
280 } |
300 } |
281 } |
301 } |
282 |
302 |
283 //to be called only when the photos plugin was activated by external means |
303 //to be called only when the photos plugin was activated by external means |
284 void GlxViewManager::deactivateCurrentView() |
304 void GlxViewManager::deactivateCurrentView() |
332 void GlxViewManager::enterMarkingMode(qint32 viewId) |
352 void GlxViewManager::enterMarkingMode(qint32 viewId) |
333 { |
353 { |
334 GlxView *view = findView ( viewId ); |
354 GlxView *view = findView ( viewId ); |
335 qDebug("GlxViewManager::enterMarkingMode view ID %d", viewId); |
355 qDebug("GlxViewManager::enterMarkingMode view ID %d", viewId); |
336 |
356 |
337 //In the case of first time create the marking mode menu( Mark All, Un Mark All ) |
|
338 if( mMenu == NULL ) { |
|
339 mMenu = new HbMenu(); |
|
340 mMenuManager->createMarkingModeMenu(mMenu); |
|
341 } |
|
342 |
|
343 if ( mMarkingToolBar == NULL) { |
357 if ( mMarkingToolBar == NULL) { |
344 createMarkingModeToolBar(); //Marking mode tool bar is different from normal mode tool bar |
358 createMarkingModeToolBar(); //Marking mode tool bar is different from normal mode tool bar |
345 } |
359 } |
346 |
360 |
347 if ( view ) { |
361 if ( view ) { |
348 view->enableMarking(); |
362 view->enableMarking(); |
349 HbMenu *menu = view->takeMenu(); //Take the owner ship of current menu |
|
350 view->setMenu(mMenu); //Set the marking mode menu |
|
351 mMenu = menu; |
|
352 view->takeToolBar(); |
363 view->takeToolBar(); |
353 view->addToolBar(mMarkingToolBar); |
364 view->addToolBar(mMarkingToolBar); |
354 mSelectionModel = view->getSelectionModel(); |
365 mSelectionModel = view->getSelectionModel(); |
355 if(mSelectionModel) |
366 if(mSelectionModel) |
356 { |
367 { |
499 { |
509 { |
500 qDebug("GlxViewManager::createActions() " ); |
510 qDebug("GlxViewManager::createActions() " ); |
501 mActionList.clear(); |
511 mActionList.clear(); |
502 |
512 |
503 //create the All tool bar button action |
513 //create the All tool bar button action |
504 HbAction* allAction = new HbAction(this); |
514 HbAction* allAction = new HbAction( this ); |
505 allAction->setData(EGlxCmdAllGridOpen); |
515 allAction->setData( EGlxCmdAllGridOpen ); |
506 mActionList.append(allAction); |
516 mActionList.append( allAction ); |
507 allAction->setIcon(HbIcon(GLXICON_ALL)) ; |
517 allAction->setIcon( HbIcon( GLXICON_ALL ) ) ; |
|
518 allAction->setObjectName( "All Action" ); |
508 |
519 |
509 //create the Album tool bar button action |
520 //create the Album tool bar button action |
510 HbAction* albumAction = new HbAction(this); |
521 HbAction* albumAction = new HbAction( this ); |
511 albumAction->setData(EGlxCmdAlbumListOpen); |
522 albumAction->setData( EGlxCmdAlbumListOpen ); |
512 mActionList.append(albumAction); |
523 mActionList.append( albumAction ); |
513 albumAction->setIcon(HbIcon(GLXICON_ALBUMS)) ; |
524 albumAction->setIcon( HbIcon( GLXICON_ALBUMS ) ) ; |
|
525 albumAction->setObjectName( "Album Action" ); |
514 |
526 |
515 //create the album tool bar button action |
527 //create the album tool bar button action |
516 HbAction* cameraAction = new HbAction(this); |
528 HbAction* cameraAction = new HbAction( this ); |
517 cameraAction->setData(EGlxCmdCameraOpen); |
529 cameraAction->setData( EGlxCmdCameraOpen ); |
518 mActionList.append(cameraAction); |
530 mActionList.append( cameraAction ); |
519 cameraAction->setIcon(HbIcon(GLXICON_CAMERA)) ; |
531 cameraAction->setIcon( HbIcon( GLXICON_CAMERA ) ) ; |
520 |
532 cameraAction->setObjectName( "Camera Action" ); |
521 |
533 |
522 //create the ovi tool bar button action |
534 //Configure the 4 th Action in the tool bar |
523 HbAction* oviAction = new HbAction(this); |
535 XQSettingsManager *ciSettingsManager = NULL; |
524 oviAction->setData(EGlxCmdOviOpen); |
536 ciSettingsManager = new XQSettingsManager(this); |
525 mActionList.append(oviAction); |
537 |
526 oviAction->setIcon(HbIcon(GLXICON_OVI)) ; |
538 |
527 |
539 XQSettingsKey* operatorLinkCenrepKey = NULL; |
|
540 operatorLinkCenrepKey = new XQSettingsKey(XQSettingsKey::TargetCentralRepository, |
|
541 KGlxCi_UidGallery, KGlxOperatorLink); |
|
542 QVariant value = ciSettingsManager->readItemValue(*operatorLinkCenrepKey); |
|
543 |
|
544 |
|
545 switch(value.toInt()) { |
|
546 case KGlxOvi: |
|
547 { |
|
548 XQSettingsKey* oviCenrepKey = NULL; |
|
549 oviCenrepKey = new XQSettingsKey(XQSettingsKey::TargetCentralRepository, |
|
550 KGlxCi_UidGallery, KGlxOvi); |
|
551 QVariant Ovivalue = ciSettingsManager->readItemValue(*oviCenrepKey, XQSettingsManager::TypeString); |
|
552 HbAction* configurableAction = new HbAction(this); |
|
553 configurableAction->setData(EGlxCmdOviOpen); |
|
554 mActionList.append(configurableAction); |
|
555 |
|
556 if ( Ovivalue.isValid() && Ovivalue.canConvert<QString>() ) { |
|
557 configurableAction->setIcon( HbIcon( Ovivalue.toString() ) ); |
|
558 } |
|
559 |
|
560 delete oviCenrepKey; |
|
561 } |
|
562 break; |
|
563 |
|
564 default: |
|
565 qDebug("GlxViewManager::Configurable Action is empty " ); |
|
566 break; |
|
567 } |
|
568 |
|
569 delete operatorLinkCenrepKey; |
|
570 delete ciSettingsManager; |
528 } |
571 } |
529 |
572 |
530 void GlxViewManager::createMarkingModeActions() |
573 void GlxViewManager::createMarkingModeActions() |
531 { |
574 { |
532 mMarkingActionList.clear(); |
575 mMarkingActionList.clear(); |
533 |
576 |
534 //create the ok tool bar button action |
577 //create the ok tool bar button action |
535 HbAction* selectAction = new HbAction(GLX_BUTTON_OK, this); |
578 HbAction* selectAction = new HbAction(GLX_BUTTON_OK, this); |
536 selectAction->setData(EGlxCmdSelect); |
579 selectAction->setData(EGlxCmdSelect); |
|
580 selectAction->setObjectName( "Select Action" ); |
537 mMarkingActionList.append(selectAction); |
581 mMarkingActionList.append(selectAction); |
538 connect( selectAction, SIGNAL(triggered( )), this, SLOT(handleAction( )), Qt::QueuedConnection ); |
582 connect( selectAction, SIGNAL(triggered( )), this, SLOT(handleAction( )), Qt::QueuedConnection ); |
539 mMarkingToolBar->addAction( selectAction ); |
583 mMarkingToolBar->addAction( selectAction ); |
540 |
584 |
541 //create the cancel tool bar button action |
585 //create the cancel tool bar button action |
542 HbAction* cancelAction = new HbAction(GLX_BUTTON_CANCEL, this); |
586 HbAction* cancelAction = new HbAction(GLX_BUTTON_CANCEL, this); |
543 cancelAction->setData(EGlxCmdCancel); |
587 cancelAction->setData(EGlxCmdCancel); |
|
588 cancelAction->setObjectName( "Cancel Action" ); |
544 mMarkingActionList.append(cancelAction); |
589 mMarkingActionList.append(cancelAction); |
545 connect( cancelAction, SIGNAL(triggered( )), this, SLOT(handleAction( )), Qt::QueuedConnection ); |
590 connect( cancelAction, SIGNAL(triggered( )), this, SLOT(handleAction( )), Qt::QueuedConnection ); |
546 mMarkingToolBar->addAction( cancelAction ); |
591 mMarkingToolBar->addAction( cancelAction ); |
547 } |
592 } |
548 |
593 |
637 { |
682 { |
638 qDebug("GlxViewManager::~GlxViewManager"); |
683 qDebug("GlxViewManager::~GlxViewManager"); |
639 HbStyleLoader::unregisterFilePath(":/data/photos.css"); |
684 HbStyleLoader::unregisterFilePath(":/data/photos.css"); |
640 |
685 |
641 removeConnection(); |
686 removeConnection(); |
|
687 |
642 delete mMenuManager; |
688 delete mMenuManager; |
643 qDebug("GlxViewManager::~GlxViewManager deleted menu manager"); |
689 qDebug("GlxViewManager::~GlxViewManager deleted menu manager"); |
|
690 delete mViewToolBar; |
|
691 delete mMarkingToolBar; |
|
692 qDebug("GlxViewManager::~GlxViewManager deleted toolbar"); |
644 |
693 |
645 while( mViewList.isEmpty( ) == FALSE){ |
694 while( mViewList.isEmpty( ) == FALSE){ |
646 delete mViewList.takeLast() ; |
695 delete mViewList.takeLast() ; |
647 } |
696 } |
648 qDebug("GlxViewManager::~GlxViewManager view deleted"); |
697 qDebug("GlxViewManager::~GlxViewManager view deleted"); |
649 |
|
650 |
698 |
651 delete mBackAction; |
699 delete mBackAction; |
652 delete mViewToolBar; |
|
653 delete mMarkingToolBar; |
|
654 delete mMenu; |
|
655 delete mProgressDialog; |
700 delete mProgressDialog; |
|
701 |
656 if ( mEffectEngine ) { |
702 if ( mEffectEngine ) { |
657 mEffectEngine->deregistertransitionEffect(); |
703 mEffectEngine->deregistertransitionEffect(); |
658 delete mEffectEngine; |
704 delete mEffectEngine; |
659 } |
705 } |
660 |
706 |