userguide/src/HelpMainWindow.cpp
branchGCC_SURGE
changeset 35 3ae60d69bf22
parent 34 4533d75b8d4e
equal deleted inserted replaced
21:e70b37c1a9d5 35:3ae60d69bf22
    16 */
    16 */
    17 
    17 
    18 #include <hbtoolbar.h>
    18 #include <hbtoolbar.h>
    19 #include <hbnotificationdialog.h>
    19 #include <hbnotificationdialog.h>
    20 #include <hbaction.h>
    20 #include <hbaction.h>
       
    21 #include <hbapplication.h>
       
    22 #include <hbactivitymanager.h>
    21 
    23 
    22 #include "HelpBaseView.h"
    24 #include "HelpBaseView.h"
    23 #include "HelpCategoryView.h"
    25 #include "HelpCategoryView.h"
    24 #include "HelpKeywordView.h"
    26 #include "HelpKeywordView.h"
    25 #include "HelpContentsView.h"
    27 #include "HelpContentsView.h"
    30 HelpMainWindow::HelpMainWindow() : 
    32 HelpMainWindow::HelpMainWindow() : 
    31 mCategoryView(NULL),
    33 mCategoryView(NULL),
    32 mKeywordView(NULL),
    34 mKeywordView(NULL),
    33 mContentsView(NULL)
    35 mContentsView(NULL)
    34 {
    36 {
       
    37     QObject::connect(qApp, SIGNAL(aboutToQuit()), this, SLOT(saveActivity()));
       
    38 	HelpDataProvider::instance()->createHelpCategory();
    35     activateCategoryView();
    39     activateCategoryView();
    36 }
    40 }
    37 
    41 
    38 HelpMainWindow::~HelpMainWindow()
    42 HelpMainWindow::~HelpMainWindow()
    39 {
    43 {
    57 			{
    61 			{
    58 				onActivateView(mPreviousViewName);
    62 				onActivateView(mPreviousViewName);
    59 			}
    63 			}
    60 			break;
    64 			break;
    61 	    default:
    65 	    default:
       
    66 			HbApplication::exit();
    62 	        break;
    67 	        break;
    63 	}
    68 	}
    64 }
    69 }
    65 
    70 
    66 void HelpMainWindow::activateCategoryView()
    71 void HelpMainWindow::activateCategoryView()
   127 {	
   132 {	
   128     activateKeywordView();
   133     activateKeywordView();
   129 	mKeywordView->loadAllContent();
   134 	mKeywordView->loadAllContent();
   130 }
   135 }
   131 
   136 
       
   137 void HelpMainWindow::saveActivity()
       
   138 {
       
   139 	HbActivityManager* activityManager = qobject_cast<HbApplication*>(qApp)->activityManager();
       
   140 
       
   141 	// clean up any previous versions of this activity from the activity manager.
       
   142 	bool ok = activityManager->removeActivity("UserGuideMainView");
       
   143 	if ( !ok )
       
   144 	{
       
   145 		//qFatal("Remove failed" );
       
   146 	}
       
   147 
       
   148 	// get a screenshot for saving to the activity manager
       
   149 	QVariantHash metadata;
       
   150 	metadata.insert("screenshot", QPixmap::grabWidget(this, rect()));
       
   151 
       
   152 	// save any data necessary to save the state
       
   153 	QByteArray serializedActivity;
       
   154 	QDataStream stream(&serializedActivity, QIODevice::WriteOnly | QIODevice::Append);
       
   155 
       
   156 	// add the activity to the activity manager
       
   157 	ok = activityManager->addActivity("UserGuideMainView", serializedActivity, metadata);
       
   158 	if ( !ok )
       
   159 	{
       
   160 		qFatal("Add failed" );
       
   161 	}
       
   162 }
       
   163 
   132 // end of file
   164 // end of file
   133 
   165