controlpanelplugins/themeplugin/src/cpthemecontrol.cpp
changeset 19 36aa4756ee82
parent 12 624337f114fe
child 17 4a9568303383
child 21 2883a5458389
equal deleted inserted replaced
12:624337f114fe 19:36aa4756ee82
    32 #include <QModelIndex>
    32 #include <QModelIndex>
    33 #include <QStandardItemModel>
    33 #include <QStandardItemModel>
    34 #include <QStandardItem>
    34 #include <QStandardItem>
    35 #include <QTranslator>
    35 #include <QTranslator>
    36 #include <QSortFilterProxyModel>
    36 #include <QSortFilterProxyModel>
       
    37 #include <QDebug>
       
    38 #include <QThread>
    37 
    39 
    38 #include <hbmainwindow.h>
    40 #include <hbmainwindow.h>
    39 #include <hbinstance.h>
    41 #include <hbinstance.h>
    40 #include "cpthemechanger.h"
    42 #include "cpthemechanger.h"
    41 
    43 
    63 */
    65 */
    64 CpThemeControl::CpThemeControl(): mThemeListView(0), 
    66 CpThemeControl::CpThemeControl(): mThemeListView(0), 
    65     mThemePreview(0), 
    67     mThemePreview(0), 
    66     mThemeChanger(0),
    68     mThemeChanger(0),
    67     mListModel(0),
    69     mListModel(0),
    68     mSortModel(0)
    70     mSortModel(0),
       
    71     mIdleTimer(0)
    69 {
    72 {
    70     mThemeChanger = new CpThemeChanger();
    73     mThemeChanger = new CpThemeChanger();
    71    
    74    
    72        
    75        
    73     QTranslator *translator = new QTranslator(this);
    76     QTranslator *translator = new QTranslator(this);
    74     QString lang = QLocale::system().name();
    77     QString lang = QLocale::system().name();
    75     QString path = "Z:/resource/qt/translations/";
    78     QString path = "Z:/resource/qt/translations/";
    76     translator->load("control_panel_" + lang, path);
    79     translator->load("control_panel_" + lang, path);
    77     qApp->installTranslator(translator);
    80     qApp->installTranslator(translator);
    78 
    81     
       
    82     mIdleTimer = new QTimer(this);
       
    83     connect(mIdleTimer, SIGNAL(timeout()), this, SLOT(themeChangeTimeout()));
       
    84     connect(hbInstance->theme(),SIGNAL(changeFinished()), this, SLOT(themeChangeFinished()));
       
    85    
    79 }
    86 }
    80 
    87 
    81 
    88 
    82 
    89 
    83 /*!
    90 /*!
   227     bool success = false;
   234     bool success = false;
   228 
   235 
   229     success = mThemeChanger->connectToServer();
   236     success = mThemeChanger->connectToServer();
   230     
   237     
   231     if (success) {
   238     if (success) {
       
   239         QThread::currentThread()->setPriority(QThread::HighPriority);  
   232         mThemeChanger->changeTheme(theme);
   240         mThemeChanger->changeTheme(theme);
   233         emit themeUpdated(mThemeChanger->currentTheme().name, mThemeChanger->currentTheme().icon);
   241         emit themeUpdated(mThemeChanger->currentTheme().name, mThemeChanger->currentTheme().icon);
   234     }
   242     }
   235 
   243 
   236     //Go back to control panel view. Close theme preview.
   244     //Go back to control panel view. Close theme preview.
   277 void CpThemeControl::triggerThemeListClose()
   285 void CpThemeControl::triggerThemeListClose()
   278 {
   286 {
   279     mThemeListView->closeView();
   287     mThemeListView->closeView();
   280 }
   288 }
   281 
   289 
       
   290 void CpThemeControl::themeChangeTimeout()
       
   291 {
       
   292     //qDebug() << "ThemeChangeTimeout " ;
       
   293     mIdleTimer->stop();
       
   294     QThread::currentThread()->setPriority(QThread::NormalPriority);    
       
   295         
       
   296 }
       
   297 
       
   298 void CpThemeControl::themeChangeFinished()
       
   299 {
       
   300     //qDebug() << "ThemeChangeFinished " ;
       
   301     mIdleTimer->start(0);
       
   302 }
       
   303 
   282 /*!
   304 /*!
   283  * Private function that sets the current index of theme list view to indicate
   305  * Private function that sets the current index of theme list view to indicate
   284  * the active theme.
   306  * the active theme.
   285  */
   307  */
   286 void CpThemeControl::setActiveThemeIndex()
   308 void CpThemeControl::setActiveThemeIndex()