controlpanelplugins/themeplugin/src/cpthemechanger.cpp
changeset 40 593f946f4fec
parent 22 a5692c68d772
equal deleted inserted replaced
22:a5692c68d772 40:593f946f4fec
    37 */
    37 */
    38 CpThemeChanger::CpThemeChanger(QObject* p) :
    38 CpThemeChanger::CpThemeChanger(QObject* p) :
    39     QObject(p),
    39     QObject(p),
    40     mCurrentTheme(0)
    40     mCurrentTheme(0)
    41 {
    41 {
    42     connect(hbInstance->theme(),SIGNAL(changeFinished()), this, SLOT(changeFinished()));
    42     if(hbInstance->theme()) {
       
    43         connect(hbInstance->theme(),SIGNAL(changeFinished()), this, SLOT(changeFinished()));
       
    44     }
    43        
    45        
    44     setCurrentTheme();
    46     setCurrentTheme();
    45 }
    47 }
    46 
    48 
    47 /*!
    49 /*!
    71          
    73          
    72     }
    74     }
    73        
    75        
    74     if(mCurrentTheme && mCurrentTheme->name() == themeName) {
    76     if(mCurrentTheme && mCurrentTheme->name() == themeName) {
    75         return;
    77         return;
    76     }
    78     } else {
    77     else {
       
    78         //buildThemeInfo creates new theme info.
    79         //buildThemeInfo creates new theme info.
    79         CpThemeInfo* tmpTheme = CpThemeUtil::buildThemeInfo(HbThemeServices::themePath(), themeName);
    80         CpThemeInfo* tmpTheme = CpThemeUtil::buildThemeInfo(HbThemeServices::themePath(), themeName);
    80          
    81          
    81         //delete old value. set the new value.
    82         //delete old value. set the new value.
    82         if(tmpTheme) {
    83         if(tmpTheme) {
    90 
    91 
    91 
    92 
    92 /*!
    93 /*!
    93  Change a theme. Returns true on success, false otherwise.
    94  Change a theme. Returns true on success, false otherwise.
    94  */
    95  */
    95 bool CpThemeChanger::changeTheme(const QString& newTheme)
    96 bool CpThemeChanger::changeTheme(const CpThemeInfo& newTheme)
    96 {
    97 {
    97     bool result = false;
    98     bool result = false;
    98     // Skip doing this if the request is for the current theme
    99     // Skip doing this if the request is for the current theme
    99     if (newTheme.isEmpty() || newTheme == mCurrentTheme->name()) {
   100     if (newTheme.name().isEmpty() || (mCurrentTheme && newTheme.name() == mCurrentTheme->name())) {
   100         return result;
   101         return result;
   101     }
   102     }
   102 
   103 
   103     QString themePath = CpThemeUtil::themePath(newTheme);
   104     QString themePath = newTheme.itemData();
   104     
   105     
   105     if(!themePath.isEmpty()) {
   106     if(!themePath.isEmpty()) {
   106         HbThemeServices::setTheme(themePath);
   107         HbThemeServices::setTheme(themePath);
   107         result = true;
   108         result = true;
   108     }
   109     }
   122  *  Slot to handle notification from theme server that theme change
   123  *  Slot to handle notification from theme server that theme change
   123  *  is done.  Notify the owner.
   124  *  is done.  Notify the owner.
   124  */
   125  */
   125 void CpThemeChanger::changeFinished()
   126 void CpThemeChanger::changeFinished()
   126 {
   127 {
   127   
       
   128     setCurrentTheme();
   128     setCurrentTheme();
   129     
       
   130     emit themeChangeFinished();
   129     emit themeChangeFinished();
   131 }
   130 }
   132 
   131 
   133 // End of file
   132 // End of file
   134 
   133