src/hbutils/theme/hbthemeservices.cpp
changeset 21 4633027730f5
parent 7 923ff622b8b9
child 23 e6ad4ef83b23
equal deleted inserted replaced
7:923ff622b8b9 21:4633027730f5
    42 #include "hbthemecommon_symbian_p.h"
    42 #include "hbthemecommon_symbian_p.h"
    43 #else
    43 #else
    44 #include "hbthemeclient_p.h"
    44 #include "hbthemeclient_p.h"
    45 #endif
    45 #endif
    46 
    46 
       
    47 #include <QSettings>
       
    48 
    47 /*!
    49 /*!
    48     Sets the active theme that is used with the Hb applications. HbTheme changed() signal will be emitted if theme change is
    50     Sets the active theme that is used with the Hb applications. HbTheme changed() signal will be emitted if theme change is
    49     applied succesfully. In addition to the active theme content loading also the underlying priority themes will be updated
    51     applied succesfully. In addition to the active theme content loading also the underlying priority themes will be updated
    50     during the theme change.
    52     during the theme change.
    51 
    53 
    85         path.append("/icons/");
    87         path.append("/icons/");
    86         path.append(info.name);
    88         path.append(info.name);
    87     }
    89     }
    88     return path;
    90     return path;
    89 }
    91 }
       
    92 
       
    93 /*!
       
    94     Returns the list of available themes.
       
    95 
       
    96     \return list of themes. First item of QPair is the unlocalized theme name
       
    97     and the second item is the absolute path to the theme.
       
    98 */
       
    99 const QList<QPair<QString, QString> > HbThemeServices::availableThemes()
       
   100 {
       
   101     QList<QPair<QString, QString> > themes;
       
   102 
       
   103     QStringList rootDirs;
       
   104 #ifdef Q_OS_SYMBIAN
       
   105     QFileInfoList driveList = QDir::drives();
       
   106     QString themesPath = "resource/hb/themes";
       
   107     foreach(const QFileInfo & drive, driveList) {
       
   108         QDir themeFolder(drive.absolutePath() + themesPath);
       
   109         if (themeFolder.exists()) {
       
   110             rootDirs << themeFolder.absolutePath();
       
   111         }
       
   112     }
       
   113 #else
       
   114     QString envDir = QDir::fromNativeSeparators(qgetenv("HB_THEMES_DIR"));
       
   115     if (!envDir.isEmpty())
       
   116         rootDirs << envDir + "/themes";
       
   117 #endif
       
   118 
       
   119     foreach(const QString &rootDir, rootDirs) {
       
   120         QDir root = rootDir;
       
   121         QDir dir = rootDir+"/icons";
       
   122         QStringList themeNamesList = dir.entryList(QDir::AllDirs|QDir::NoDotAndDotDot,QDir::Name);
       
   123         foreach(QString themeName, themeNamesList) {
       
   124             QDir iconThemePath(dir.path()+'/'+themeName);
       
   125             QFile themeIndexFile(root.path()+'/'+themeName+".themeindex");
       
   126             if(themeIndexFile.exists() && iconThemePath.exists("index.theme")) {
       
   127                 QSettings iniSetting(iconThemePath.path()+"/index.theme",QSettings::IniFormat);
       
   128                 iniSetting.beginGroup("Icon Theme");
       
   129                 bool hidden = iniSetting.value("Hidden",true).toBool();
       
   130                 QString name = iniSetting.value("Name").toString();
       
   131                 iniSetting.endGroup();
       
   132                 if(!hidden && !name.isEmpty()) {
       
   133                     themes.append(QPair<QString,QString>(name, iconThemePath.absolutePath()));
       
   134                 }
       
   135             }
       
   136         }
       
   137     }
       
   138 
       
   139     return themes;
       
   140 }