void KNThemeManager::loadThemeFiles(const QString &themeDirPath) { //Clear the previous theme list. m_themeList.clear(); //Add the default theme as the first item in the list. addTheme("Default", "://configure/default.json", QPixmap()); //The structure of a theme directory. /* Theme * |-<Theme Name> * | |-<Theme Name>.json * | |-<Theme Name>.png */ //Check the folder exist. If no, return. QDir themeFolder(themeDirPath); if(!themeFolder.exists()) { return; } //Get all the folder in the theme folder. QFileInfoList folderList=themeFolder.entryInfoList(); for(QFileInfoList::const_iterator i=folderList.constBegin(); i!=folderList.constEnd(); ++i) { QString themeName=(*i).fileName(); //Ignore if the current info is not folder, dot(.) and dot-dot(..). if(!(*i).isDir() || themeName=="." || themeName=="..") { continue; } //Get the theme file and the preview image. QFileInfo themeFile((*i).absoluteFilePath()+"/"+themeName+".json"), previewFile((*i).absoluteFilePath()+"/"+themeName+".png"); if(themeFile.exists()) { //Check the preview image. QPixmap previewImage; if(previewFile.exists()) { previewImage.load(previewFile.absoluteFilePath()); if(previewImage.isNull()) { //! FIXME: Set the preview to no image. ; } } else { //! FIXME: Set the preview to no image. ; } //Add the new theme addTheme(themeName, themeFile.absoluteFilePath(), previewImage); } } }
//----------------------------------------------------------------------------- void SplashInstaller::readThemesList() { mThemesList->clear(); // Read local themes const QStringList entryList = KGlobal::dirs()->resourceDirs("ksplashthemes"); //kDebug() << "readThemesList: " << entryList; QDir dir; QStringList subdirs; QStringList::ConstIterator name; for(name = entryList.constBegin(); name != entryList.constEnd(); name++) { dir = *name; if (!dir.exists()) continue; subdirs = dir.entryList( QDir::Dirs ); // kDebug() << "readThemesList: " << subdirs; // TODO: Make sure it contains a *.rc file. for (QStringList::const_iterator l = subdirs.constBegin(); l != subdirs.constEnd(); l++ ) if ( !(*l).startsWith(QString(".")) ) { mThemesList->blockSignals( true ); // Don't activate any theme until all themes are loaded. addTheme(dir.path(),*l); mThemesList->blockSignals( false ); } } }
//--------------------------------------------------------------------------- // // Get list of all themes // void AmorDialog::readThemes() { QStringList files; // Non-recursive search for theme files, with the relative paths stored // in files so that absolute paths are not used. KGlobal::dirs()->findAllResources("appdata", "*rc", false, false, files); for (QStringList::ConstIterator it = files.begin(); it != files.end(); it++) addTheme(*it); }