src/hbcore/theme/hbtheme.cpp
changeset 5 627c4a0fd0e7
parent 3 11d3954df52a
child 6 c3690ec91ef8
equal deleted inserted replaced
3:11d3954df52a 5:627c4a0fd0e7
    83     Returns the non localized name of the currently active theme.
    83     Returns the non localized name of the currently active theme.
    84     
    84     
    85 */
    85 */
    86 QString HbTheme::name() const
    86 QString HbTheme::name() const
    87 {
    87 {
    88     return d_ptr->currentTheme;
    88     return d_ptr->iconTheme.name();
    89 }
    89 }
    90 
    90 
    91 /*!
    91 /*!
    92     Returns the non localized description of the currently active theme.
    92     Returns the non localized description of the currently active theme.
    93 */
    93 */
   143 /*!
   143 /*!
   144     Retrieves the current theme from setting
   144     Retrieves the current theme from setting
   145 */
   145 */
   146 void HbThemePrivate::fetchCurrentThemeFromSettings()
   146 void HbThemePrivate::fetchCurrentThemeFromSettings()
   147 {
   147 {
       
   148     HbThemeIndexInfo info = HbThemeUtils::getThemeIndexInfo(ActiveTheme);
       
   149     if (info.themeIndexOffset > 0) {
       
   150         currentTheme = info.name;
       
   151         return;
       
   152     }
       
   153     
       
   154     // Fallback to settings
   148     currentTheme = HbThemeUtils::getThemeSetting(HbThemeUtils::CurrentThemeSetting);
   155     currentTheme = HbThemeUtils::getThemeSetting(HbThemeUtils::CurrentThemeSetting);
   149     if (currentTheme.trimmed().isEmpty()){
   156     if (currentTheme.trimmed().isEmpty()){
   150         currentTheme = HbThemeUtils::defaultTheme().name;
   157         currentTheme = HbThemeUtils::defaultTheme().name;
   151         HbThemeUtils::setThemeSetting(HbThemeUtils::CurrentThemeSetting, currentTheme);
       
   152     }
   158     }
   153 }
   159 }
   154 
   160 
   155 /*!
   161 /*!
   156     Handles theme-change request
   162     Handles theme-change request
   158 void HbThemePrivate::handleThemeChange(const QString &str)
   164 void HbThemePrivate::handleThemeChange(const QString &str)
   159 {
   165 {
   160     Q_Q(HbTheme);
   166     Q_Q(HbTheme);
   161     QString newTheme;
   167     QString newTheme;
   162     if (str.isEmpty()) {
   168     if (str.isEmpty()) {
   163         newTheme = HbThemeUtils::getThemeSetting(HbThemeUtils::CurrentThemeSetting);
   169         HbThemeIndexInfo info = HbThemeUtils::getThemeIndexInfo(ActiveTheme);
       
   170         if (info.themeIndexOffset > 0) {
       
   171             newTheme = info.name;
       
   172         } else {
       
   173             newTheme = HbThemeUtils::getThemeSetting(HbThemeUtils::CurrentThemeSetting);
       
   174         }
   164     } else {
   175     } else {
   165         newTheme = str;
   176         newTheme = str;
   166         // Update the new currentTheme setting in HbThemeUtils.
   177         // Update the new currentTheme to local settings in HbThemeUtils.
   167         HbThemeUtils::updateThemeSetting(HbThemeUtils::CurrentThemeSetting, newTheme);
   178         HbThemeUtils::updateThemeSetting(HbThemeUtils::CurrentThemeSetting, newTheme);
   168     }
   179     }
   169 
   180 
   170     iconTheme.setCurrentTheme(newTheme);
   181     iconTheme.setCurrentTheme(newTheme);
   171     HbColorTheme::instance()->setCurrentTheme(newTheme);
   182     HbColorTheme::instance()->setCurrentTheme(newTheme);
   172     HbEffectTheme::instance()->setCurrentTheme(newTheme);
   183     HbEffectTheme::instance()->setCurrentTheme(newTheme);
   173     
   184     
   174     // The server sends the signal only if the theme is changed from the previous theme
   185     // The server sends the signal only if the theme is changed from the previous theme
   175     // Hence here, we need not check whether the theme differs from currentTheme or not.
   186     // Hence here, we need not check whether the theme differs from currentTheme or not.
   176     if(currentTheme != newTheme) {
   187     currentTheme = newTheme;
   177         currentTheme = newTheme;
   188     // This should be used to replace pixmaps from the old theme with the pixmaps from the new theme
   178         // This should be used to replace pixmaps from the old theme with the pixmaps from the new theme
   189     // In application side this is needed only when icon size can be different in different theme.
   179         // In application side this is needed only when icon size can be different in different theme.
   190     iconTheme.emitUpdateIcons();
   180         iconTheme.emitUpdateIcons();
   191 
   181 
   192     emit q->changed();
   182         emit q->changed();
   193     // This signal should be used to update the screen after the theme change - it's handled by HbInstance.
   183         // This signal should be used to update the screen after the theme change - it's handled by HbInstance.
   194     emit q->changeFinished();
   184         emit q->changeFinished();
       
   185     }
       
   186 }
   195 }
   187 
   196 
   188 /*!
   197 /*!
   189     Clears the contents to reload new css files
   198     Clears the contents to reload new css files
   190 */
   199 */