--- a/controlpanelplugins/themeplugin/src/cpthemecontrol.cpp Fri Jun 11 13:39:17 2010 +0300
+++ b/controlpanelplugins/themeplugin/src/cpthemecontrol.cpp Wed Jun 23 18:13:38 2010 +0300
@@ -33,6 +33,7 @@
#include <QTranslator>
#include <QSortFilterProxyModel>
#include <QThread>
+#include <QTimer>
#include <hbmainwindow.h>
#include <hbinstance.h>
@@ -42,7 +43,9 @@
#include "cpthemelistview.h"
#include "cpthemepreview.h"
-static const QString KPlaceholderPreview = ":/image/themePreview.svg";
+#include <hbdialog.h>
+#include <hblabel.h>
+
/*!
Helper function to fetch the main window.
@@ -65,10 +68,10 @@
mThemeChanger(0),
mListModel(0),
mSortModel(0),
- mIdleTimer(0)
+ mThemeChangeFinished(false),
+ mWaitDialog(0)
{
mThemeChanger = new CpThemeChanger();
-
QTranslator *translator = new QTranslator(this);
QString lang = QLocale::system().name();
@@ -76,14 +79,11 @@
translator->load("control_panel_" + lang, path);
qApp->installTranslator(translator);
- mIdleTimer = new QTimer(this);
- connect(mIdleTimer, SIGNAL(timeout()), this, SLOT(themeChangeTimeout()));
connect(hbInstance->theme(),SIGNAL(changeFinished()), this, SLOT(themeChangeFinished()));
}
-
/*!
destorys the list view, preview and theme changer objects.
*/
@@ -97,6 +97,9 @@
delete mThemePreview;
mThemePreview = 0;
+
+ delete mWaitDialog;
+ mWaitDialog = 0;
}
/*!
@@ -217,8 +220,7 @@
} else {
mThemePreview->setThemeInfo(themeInfo);
}
- //TODO: use qtTrId(text_id).
- mThemePreview->setTitle(tr("Control Panel"));
+ mThemePreview->setTitle(hbTrId("txt_cp_title_control_panel"));
mWindow->setCurrentView(mThemePreview);
@@ -238,13 +240,14 @@
mThemeChanger->changeTheme(theme);
emit themeUpdated(mThemeChanger->currentTheme().name, mThemeChanger->currentTheme().icon);
}
-
- //Go back to control panel view. Close theme preview.
- previewClosed();
- //ask the themelistview to close. Control Panel will
- //take care of removing it from window.
- triggerThemeListClose();
-
+
+ //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()));
+
+ mThemeChangeFinished = false;
+
}
/*!
@@ -288,14 +291,49 @@
void CpThemeControl::themeChangeTimeout()
{
- mIdleTimer->stop();
+ //Theme change is finished and idle timer has timed out,
+ //so revert back the application priority to normal
+ //and go back to control panel view.
+ if(mWaitDialog && mWaitDialog->isVisible()) {
+ mWaitDialog->hide();
+ }
+
+ previewClosed();
+ //ask the themelistview to close. Control Panel will
+ //take care of removing it from window.
+ triggerThemeListClose();
+
QThread::currentThread()->setPriority(QThread::NormalPriority);
-
+}
+
+void CpThemeControl::themeWaitTimeout()
+{
+ //If after this timeOut, theme change is still in progress,
+ //show a processing dialog.
+ if(!mThemeChangeFinished)
+ {
+ if(!mWaitDialog) {
+ mWaitDialog = new HbDialog();
+ mWaitDialog->setModal(false);
+ mWaitDialog->setDismissPolicy(HbPopup::NoDismiss);
+ //TODO: need localized text for Hb Dialog
+ // Create and set HbLabel as content widget.
+ HbLabel *label = new HbLabel("Processing ...");
+ label->setAlignment(Qt::AlignCenter);
+ mWaitDialog->setContentWidget(label);
+ }
+ // as we do not need any signals, calling show() instead of open()
+ mWaitDialog->show();
+ }
}
void CpThemeControl::themeChangeFinished()
{
- mIdleTimer->start(0);
+ //Theme change is done. Start an idle timer to let the UI
+ //finish remaining tasks.
+ QTimer::singleShot(0, this, SLOT(themeChangeTimeout()));
+ mThemeChangeFinished = true;
+
}
/*!