controlpanelplugins/themeplugin/src/cpthemecontrol.cpp
changeset 26 808caa51b78b
parent 22 a5692c68d772
child 28 e0b83131558d
equal deleted inserted replaced
22:a5692c68d772 26:808caa51b78b
    48 #include "cpthemelistmodel.h"
    48 #include "cpthemelistmodel.h"
    49 
    49 
    50 #include <hbdialog.h>
    50 #include <hbdialog.h>
    51 #include <hblabel.h>
    51 #include <hblabel.h>
    52 
    52 
       
    53 //time out time before showing a processing dialog.
       
    54 static const int KThemeChangeTimeOutMilliSeconds = 1000;  
    53 
    55 
    54 /*!
    56 /*!
    55 	Helper function to fetch the main window.
    57 	Helper function to fetch the main window.
    56 */
    58 */
    57 
    59 
   239         themeInfo.setLandscapePreviewIcon(data.value<HbIcon>());
   241         themeInfo.setLandscapePreviewIcon(data.value<HbIcon>());
   240     }
   242     }
   241     
   243     
   242    //Set up the theme preview and set it to
   244    //Set up the theme preview and set it to
   243     //the current view of main window.
   245     //the current view of main window.
       
   246 
   244     HbMainWindow*  mWindow = ::mainWindow();
   247     HbMainWindow*  mWindow = ::mainWindow();
   245    
   248    
   246     if(!mThemePreview){
   249     if(!mThemePreview){
   247         mThemePreview = new CpThemePreview(themeInfo);
   250         mThemePreview = new CpThemePreview(themeInfo);
   248         mWindow->addView(mThemePreview);
   251         mWindow->addView(mThemePreview);
   271     if(mThemeChanger->changeTheme(theme)) {
   274     if(mThemeChanger->changeTheme(theme)) {
   272     
   275     
   273         //Start a timer. If theme change takes more than 1 seconds,
   276         //Start a timer. If theme change takes more than 1 seconds,
   274         //we will show a dialog (mWaitDialog) until theme change
   277         //we will show a dialog (mWaitDialog) until theme change
   275         //is done (themeChangeFinished is called).
   278         //is done (themeChangeFinished is called).
   276         QTimer::singleShot(1000, this, SLOT(themeWaitTimeout()));
   279         QTimer::singleShot(KThemeChangeTimeOutMilliSeconds, this, SLOT(themeWaitTimeout()));
   277         
   280         
   278         mThemeChangeFinished = false;
   281         mThemeChangeFinished = false;
   279     } else {
   282     } else {
   280         //theme change failed, go back to control panel.
   283         //theme change failed, go back to control panel.
   281         previewClosed();
   284         previewClosed();
   290 void CpThemeControl::previewClosed()
   293 void CpThemeControl::previewClosed()
   291 {
   294 {
   292     //The theme preview closed, go back
   295     //The theme preview closed, go back
   293     //to theme list view.
   296     //to theme list view.
   294     HbMainWindow*  mainWindow = ::mainWindow();
   297     HbMainWindow*  mainWindow = ::mainWindow();
   295 	mainWindow->removeView(mThemePreview);
   298     if(mThemePreview){
   296     mThemePreview->deleteLater();
   299         mainWindow->removeView(mThemePreview);
   297     mThemePreview = 0;
   300         mThemePreview->deleteLater();
       
   301         mThemePreview = 0;
       
   302     }
   298   
   303   
   299     //reset the current index to active theme, so that the selection remains on current
   304     //reset the current index to active theme, so that the selection remains on current
   300     //theme even though another list item is selected.
   305     //theme even though another list item is selected.
   301     setActiveThemeIndex();
   306     setActiveThemeIndex();
   302 	mainWindow->setCurrentView(mThemeListView);   
   307 	mainWindow->setCurrentView(mThemeListView);   
   342 
   347 
   343 void CpThemeControl::themeWaitTimeout()
   348 void CpThemeControl::themeWaitTimeout()
   344 {
   349 {
   345     //If after this timeOut, theme change is still in progress,
   350     //If after this timeOut, theme change is still in progress,
   346     //show a processing dialog.
   351     //show a processing dialog.
   347     if(!mThemeChangeFinished)
   352     if(!mThemeChangeFinished){
   348     {
       
   349         if(!mWaitDialog) {
   353         if(!mWaitDialog) {
   350             mWaitDialog = new HbDialog();
   354             mWaitDialog = new HbDialog();
   351             mWaitDialog->setDismissPolicy(HbPopup::NoDismiss);
   355             mWaitDialog->setDismissPolicy(HbPopup::NoDismiss);
   352             mWaitDialog->setModal(false);
   356             mWaitDialog->setModal(false);
   353             mWaitDialog->setTimeout(HbPopup::NoTimeout);
   357             mWaitDialog->setTimeout(HbPopup::NoTimeout);
   354             //TODO: need localized text for Hb Dialog
       
   355             // Create and set HbLabel as content widget.
   358             // Create and set HbLabel as content widget.
   356             HbLabel *label = new HbLabel("Processing ...");
   359             QString processingText = hbTrId("txt_common_info_processing") + QString("...");
       
   360             HbLabel *label = new HbLabel(processingText);
   357             label->setAlignment(Qt::AlignCenter);
   361             label->setAlignment(Qt::AlignCenter);
   358             mWaitDialog->setContentWidget(label);
   362             mWaitDialog->setContentWidget(label);
   359         }
   363         }
   360        // as we do not need any signals, calling show() instead of open()
   364        // as we do not need any signals, calling show() instead of open()
   361        mWaitDialog->show();
   365        mWaitDialog->show();