diff -r 19394c261aa5 -r e79ce701c376 controlpanelplugins/themeplugin/src/cpthemecontrol.cpp --- a/controlpanelplugins/themeplugin/src/cpthemecontrol.cpp Tue Jul 06 14:17:10 2010 +0300 +++ b/controlpanelplugins/themeplugin/src/cpthemecontrol.cpp Wed Aug 18 09:49:35 2010 +0300 @@ -50,6 +50,8 @@ #include #include +//time out time before showing a processing dialog. +static const int KThemeChangeTimeOutMilliSeconds = 2000; /*! Helper function to fetch the main window. @@ -126,8 +128,8 @@ //connect to signal for selecting a list item. - connect(mThemeListView,SIGNAL(newThemeSelected(const QModelIndex&)), - this,SLOT(newThemeSelected(const QModelIndex&))); + connect(mThemeListView,SIGNAL(newThemeSelected(QModelIndex)), + this,SLOT(newThemeSelected(QModelIndex))); //handle signal for list view closing. (e.g Back softkey pressed) connect(mThemeListView,SIGNAL(aboutToClose()), @@ -223,6 +225,11 @@ themeInfo.setName(data.toString()); } + data = index.data(CpThemeListModel::ItemDataRole); + if(data.isValid()) { + themeInfo.setItemData(data.toString()); + } + //get theme icon. data = index.data(Qt::DecorationRole); if(data.isValid()) { @@ -239,8 +246,12 @@ themeInfo.setLandscapePreviewIcon(data.value()); } + +#ifdef CP_THEME_PREVIEW_DEFINED + //Set up the theme preview and set it to //the current view of main window. + HbMainWindow* mWindow = ::mainWindow(); if(!mThemePreview){ @@ -250,21 +261,24 @@ connect(mThemePreview,SIGNAL(aboutToClose()), this, SLOT(previewClosed())); - connect(mThemePreview, SIGNAL(applyTheme(const QString&)), - this, SLOT(themeApplied(const QString&))); + connect(mThemePreview, SIGNAL(applyTheme(CpThemeInfo)), + this, SLOT(themeApplied(CpThemeInfo))); } else { mThemePreview->setThemeInfo(themeInfo); } mThemePreview->setTitle(hbTrId("txt_cp_title_control_panel")); mWindow->setCurrentView(mThemePreview); +#else + themeApplied(themeInfo); +#endif } /*! Slot called when a Select key is pressed in theme preview view. */ -void CpThemeControl::themeApplied(const QString& theme) +void CpThemeControl::themeApplied(const CpThemeInfo& theme) { QThread::currentThread()->setPriority(QThread::HighPriority); @@ -273,13 +287,18 @@ //Start a timer. If theme change takes more than 1 seconds, //we will show a dialog (mWaitDialog) until theme change //is done (themeChangeFinished is called). - QTimer::singleShot(1000, this, SLOT(themeWaitTimeout())); + QTimer::singleShot(KThemeChangeTimeOutMilliSeconds, this, SLOT(themeWaitTimeout())); mThemeChangeFinished = false; } else { //theme change failed, go back to control panel. +#ifdef CP_THEME_PREVIEW_DEFINED previewClosed(); triggerThemeListClose(); +#else + setActiveThemeIndex(); +#endif + } } @@ -292,9 +311,11 @@ //The theme preview closed, go back //to theme list view. HbMainWindow* mainWindow = ::mainWindow(); - mainWindow->removeView(mThemePreview); - mThemePreview->deleteLater(); - mThemePreview = 0; + if(mThemePreview){ + mainWindow->removeView(mThemePreview); + mThemePreview->deleteLater(); + mThemePreview = 0; + } //reset the current index to active theme, so that the selection remains on current //theme even though another list item is selected. @@ -331,12 +352,19 @@ if(mWaitDialog && mWaitDialog->isVisible()) { mWaitDialog->hide(); } - - previewClosed(); - //ask the themelistview to close. Control Panel will - //take care of removing it from window. - triggerThemeListClose(); - + +#ifdef CP_THEME_PREVIEW_DEFINED + previewClosed(); + //ask the themelistview to close. Control Panel will + //take care of removing it from window. + triggerThemeListClose(); +#else + setActiveThemeIndex(); + +#endif + + + QThread::currentThread()->setPriority(QThread::NormalPriority); } @@ -344,16 +372,15 @@ { //If after this timeOut, theme change is still in progress, //show a processing dialog. - if(!mThemeChangeFinished) - { + if(!mThemeChangeFinished){ if(!mWaitDialog) { mWaitDialog = new HbDialog(); mWaitDialog->setDismissPolicy(HbPopup::NoDismiss); mWaitDialog->setModal(false); mWaitDialog->setTimeout(HbPopup::NoTimeout); - //TODO: need localized text for Hb Dialog // Create and set HbLabel as content widget. - HbLabel *label = new HbLabel("Processing ..."); + QString processingText = hbTrId("txt_common_info_processing") + QString("..."); + HbLabel *label = new HbLabel(processingText); label->setAlignment(Qt::AlignCenter); mWaitDialog->setContentWidget(label); } @@ -389,6 +416,9 @@ //set current index. mThemeListView->themeList()->setCurrentIndex(sourceIndex, QItemSelectionModel::SelectCurrent); } + else { + mThemeListView->themeList()->setCurrentIndex(QModelIndex(), QItemSelectionModel::Clear); + } }