controlpanelplugins/themeplugin/src/cpthemechanger_p.cpp
changeset 24 f5dfdd5e4a1b
parent 17 4a9568303383
equal deleted inserted replaced
17:4a9568303383 24:f5dfdd5e4a1b
    35 #if !defined(Q_OS_SYMBIAN)
    35 #if !defined(Q_OS_SYMBIAN)
    36     #include <stdio.h>
    36     #include <stdio.h>
    37     static const char* KThemePathKey = "HB_THEMES_DIR";
    37     static const char* KThemePathKey = "HB_THEMES_DIR";
    38 #endif
    38 #endif
    39     static const QString KDefaultTheme = "sfblacktheme";
    39     static const QString KDefaultTheme = "sfblacktheme";
    40     
    40     static const QString KDefaultThemeIcon = ":/image/themePreview.nvg";
       
    41     static const QString KPreviewThumbnailNVG = "/scalable/qtg_graf_theme_preview_thumbnail.nvg";
    41     static const QString KPreviewThumbnailSVG = "/scalable/qtg_graf_theme_preview_thumbnail.svg";
    42     static const QString KPreviewThumbnailSVG = "/scalable/qtg_graf_theme_preview_thumbnail.svg";
    42     
    43     
       
    44     static const QString KPreviewPrtNVG =       "/scalable/qtg_graf_theme_preview_prt.nvg";
       
    45     static const QString KPreviewLscNVG =       "/scalable/qtg_graf_theme_preview_lsc.nvg";
    43     static const QString KPreviewPrtSVG =       "/scalable/qtg_graf_theme_preview_prt.svg";
    46     static const QString KPreviewPrtSVG =       "/scalable/qtg_graf_theme_preview_prt.svg";
    44     static const QString KPreviewLscSVG =       "/scalable/qtg_graf_theme_preview_lsc.svg";
    47     static const QString KPreviewLscSVG =       "/scalable/qtg_graf_theme_preview_lsc.svg";
    45     
    48    
       
    49     static const QString KBackgroundPrtNVG =    "/scalable/qtg_graf_screen_bg_prt.nvg";
       
    50     static const QString KBackgroundLscNVG =    "/scalable/qtg_graf_screen_bg_lsc.nvg";
    46     static const QString KBackgroundPrtSVG =    "/scalable/qtg_graf_screen_bg_prt.svg";
    51     static const QString KBackgroundPrtSVG =    "/scalable/qtg_graf_screen_bg_prt.svg";
    47     static const QString KBackgroundLscSVG =    "/scalable/qtg_graf_screen_bg_lsc.svg";
    52     static const QString KBackgroundLscSVG =    "/scalable/qtg_graf_screen_bg_lsc.svg";
    48     
    53     
    49     static const QString KBackgroundPrtPNG =    "/pixmap/qtg_graf_screen_bg_prt.png";                     
    54     static const QString KBackgroundPrtPNG =    "/pixmap/qtg_graf_screen_bg_prt.png";                     
    50     static const QString KBackgroundLscPNG =    "/pixmap/qtg_graf_screen_bg_lsc.png";
    55     static const QString KBackgroundLscPNG =    "/pixmap/qtg_graf_screen_bg_lsc.png";
   174                     QString previewPathLsc = iniSetting.value("PreviewIconPath_lsc").toString();
   179                     QString previewPathLsc = iniSetting.value("PreviewIconPath_lsc").toString();
   175                     if (name.isEmpty()) {
   180                     if (name.isEmpty()) {
   176                         continue;
   181                         continue;
   177                     }
   182                     }
   178                     
   183                     
   179                     QString fullPathToIcon(iconThemePath.path() + iconPath);
   184                     QString fullPathToIcon(iconThemePath.path());
   180                     
   185                      
   181                     if(iconPath.isEmpty()|| !QFileInfo(fullPathToIcon).exists()){
   186                     if(iconPath.isEmpty()|| !QFileInfo(fullPathToIcon + iconPath).exists()){
   182                        //Set thumbnail
   187                        //Set thumbnail
   183                         if(QFileInfo(fullPathToIcon + KPreviewThumbnailSVG).exists()){
   188                         if(QFileInfo(fullPathToIcon + KPreviewThumbnailNVG).exists()){
       
   189                             nameIconPair.icon = HbIcon(fullPathToIcon + KPreviewThumbnailNVG);
       
   190                         }else if(QFileInfo(fullPathToIcon + KPreviewThumbnailSVG).exists()){
   184                             nameIconPair.icon = HbIcon(fullPathToIcon + KPreviewThumbnailSVG);
   191                             nameIconPair.icon = HbIcon(fullPathToIcon + KPreviewThumbnailSVG);
   185                         }else if(QFileInfo(fullPathToIcon + KBackgroundPrtSVG).exists()){
   192                         }else if(QFileInfo(fullPathToIcon + KBackgroundPrtNVG).exists()){
       
   193                             nameIconPair.icon = HbIcon(fullPathToIcon + KBackgroundPrtNVG);
       
   194                         } else if(QFileInfo(fullPathToIcon + KBackgroundPrtSVG).exists()){
   186                             nameIconPair.icon = HbIcon(fullPathToIcon + KBackgroundPrtSVG);
   195                             nameIconPair.icon = HbIcon(fullPathToIcon + KBackgroundPrtSVG);
   187                         } else if(QFileInfo(fullPathToIcon + KBackgroundPrtPNG).exists()){
   196                         } else if(QFileInfo(fullPathToIcon + KBackgroundPrtPNG).exists()){
   188                             nameIconPair.icon = HbIcon(fullPathToIcon + KBackgroundPrtPNG);
   197                             nameIconPair.icon = HbIcon(fullPathToIcon + KBackgroundPrtPNG); 
       
   198                         }else{
       
   199                             nameIconPair.icon = HbIcon(KDefaultThemeIcon);
       
   200                         }
       
   201 
       
   202                     } else {
       
   203                         nameIconPair.icon = HbIcon(fullPathToIcon + iconPath);
       
   204                     }
       
   205                     
       
   206                     //Portrait preview
       
   207                     
       
   208                     if(previewPathPrt.isEmpty() || !QFileInfo(fullPathToIcon + previewPathPrt).exists()) {
       
   209                     
       
   210                         if(QFileInfo(fullPathToIcon + KPreviewPrtNVG).exists()){
       
   211                             nameIconPair.portraitPreviewIcon = HbIcon(fullPathToIcon + KPreviewPrtNVG);
       
   212                         }else if(QFileInfo(fullPathToIcon + KPreviewPrtSVG).exists()){
       
   213                             nameIconPair.portraitPreviewIcon = HbIcon(fullPathToIcon + KPreviewPrtSVG);
       
   214                         }else if(QFileInfo(fullPathToIcon + KBackgroundPrtNVG).exists()){
       
   215                             nameIconPair.portraitPreviewIcon = HbIcon(fullPathToIcon + KBackgroundPrtNVG);
       
   216                         } else if(QFileInfo(fullPathToIcon + KBackgroundPrtSVG).exists()){
       
   217                             nameIconPair.portraitPreviewIcon = HbIcon(fullPathToIcon + KBackgroundPrtSVG);
       
   218                         } else if(QFileInfo(fullPathToIcon + KBackgroundPrtPNG).exists()){
       
   219                             nameIconPair.portraitPreviewIcon = HbIcon(fullPathToIcon + KBackgroundPrtPNG);
   189                         } else{
   220                         } else{
   190                             nameIconPair.icon = HbIcon(":/image/themePreview.svg");
   221                             nameIconPair.portraitPreviewIcon = HbIcon(KDefaultThemeIcon);
   191                         }
   222                         }
   192                     } else {
   223                     }
   193                         nameIconPair.icon = HbIcon(fullPathToIcon);
   224                     else {
   194                     }
   225                         nameIconPair.portraitPreviewIcon = HbIcon(fullPathToIcon + previewPathPrt);
   195                     
   226                     }
   196                     //Portrait preview
   227                     
   197                     QString fullPathToPreviewPrt = (iconThemePath.path() + previewPathPrt );
   228                     //Landscape preview
   198                     
   229                     
   199                     if(previewPathPrt.isEmpty() || !QFileInfo(fullPathToPreviewPrt).exists()) {
   230                     if(previewPathLsc.isEmpty() || !QFileInfo(fullPathToIcon + previewPathLsc).exists()) {
   200                     
   231                         if(QFileInfo(fullPathToIcon + KPreviewLscNVG).exists()){
   201                         if(QFileInfo(fullPathToPreviewPrt + KPreviewPrtSVG).exists()){
   232                             nameIconPair.landscapePreviewIcon = HbIcon(fullPathToIcon + KPreviewLscNVG);
   202                             nameIconPair.portraitPreviewIcon = HbIcon(fullPathToPreviewPrt + KPreviewPrtSVG);
   233                         }else if(QFileInfo(fullPathToIcon + KPreviewLscSVG).exists()){
   203                         }else if(QFileInfo(fullPathToPreviewPrt + KBackgroundPrtSVG).exists()){
   234                             nameIconPair.landscapePreviewIcon = HbIcon(fullPathToIcon + KPreviewLscSVG);
   204                             nameIconPair.portraitPreviewIcon = HbIcon(fullPathToPreviewPrt + KBackgroundPrtSVG);
   235                         }else if(QFileInfo(fullPathToIcon + KBackgroundLscNVG).exists()){
   205                         } else if(QFileInfo(fullPathToPreviewPrt + KBackgroundPrtPNG).exists()){
   236                             nameIconPair.landscapePreviewIcon = HbIcon(fullPathToIcon + KBackgroundLscNVG);
   206                             nameIconPair.portraitPreviewIcon = HbIcon(fullPathToPreviewPrt + KBackgroundPrtPNG);
   237                         } else if(QFileInfo(fullPathToIcon + KBackgroundLscSVG).exists()){
       
   238                             nameIconPair.landscapePreviewIcon = HbIcon(fullPathToIcon + KBackgroundLscSVG);
       
   239                         } else if(QFileInfo(fullPathToIcon + KBackgroundLscPNG).exists()){
       
   240                             nameIconPair.landscapePreviewIcon = HbIcon(fullPathToIcon + KBackgroundLscPNG);
   207                         } else{
   241                         } else{
   208                             nameIconPair.portraitPreviewIcon = HbIcon(":/image/themePreview.svg");
   242                             nameIconPair.landscapePreviewIcon = HbIcon(KDefaultThemeIcon);
   209                         }
   243                         }
   210                     }
   244                     }
   211                     else {
   245                     else {
   212                         nameIconPair.portraitPreviewIcon = HbIcon(fullPathToPreviewPrt);
   246                         nameIconPair.landscapePreviewIcon = HbIcon(fullPathToIcon + previewPathLsc);
   213                     }
       
   214                     
       
   215                     //Landscape preview
       
   216                     QString fullPathToPreviewLsc = (iconThemePath.path() + previewPathLsc );
       
   217                                     
       
   218                     if(previewPathLsc.isEmpty() || !QFileInfo(fullPathToPreviewLsc).exists()) {
       
   219                                 
       
   220                         if(QFileInfo(fullPathToPreviewLsc + KPreviewLscSVG).exists()){
       
   221                             nameIconPair.landscapePreviewIcon = HbIcon(fullPathToPreviewLsc + KPreviewLscSVG);
       
   222                         }else if(QFileInfo(fullPathToPreviewLsc + KBackgroundLscSVG).exists()){
       
   223                             nameIconPair.landscapePreviewIcon = HbIcon(fullPathToPreviewLsc + KBackgroundLscSVG);
       
   224                         } else if(QFileInfo(fullPathToPreviewLsc + KBackgroundLscPNG).exists()){
       
   225                             nameIconPair.landscapePreviewIcon = HbIcon(fullPathToPreviewLsc + KBackgroundLscPNG);
       
   226                         } else{
       
   227                             nameIconPair.landscapePreviewIcon = HbIcon(":/image/themePreview.svg");
       
   228                         }
       
   229                     }
       
   230                     else {
       
   231                         nameIconPair.landscapePreviewIcon = HbIcon(fullPathToPreviewLsc);
       
   232                     }
   247                     }
   233                 
   248                 
   234                     nameIconPair.name = name;
   249                     nameIconPair.name = name;
   235                                         
   250                                         
   236                     mThemeList.append(nameIconPair);
   251                     mThemeList.append(nameIconPair);
   259     if (mCurrentTheme.name == KDefaultTheme)
   274     if (mCurrentTheme.name == KDefaultTheme)
   260     {
   275     {
   261         // Include default
   276         // Include default
   262          CpThemeChanger::ThemeInfo def;
   277          CpThemeChanger::ThemeInfo def;
   263          def.name = KDefaultTheme;
   278          def.name = KDefaultTheme;
   264          def.icon = HbIcon(":/image/themePreview.svg");
   279          def.icon = HbIcon(KDefaultThemeIcon);
   265          mThemeList.append(def);
   280          mThemeList.append(def);
   266   
   281   
   267          mCurrentTheme = def;
   282          mCurrentTheme = def;
   268     }
   283     }
   269 
   284