void PlasmaThemeListModel::refresh() { reset(); clearThemeList(); // get all desktop themes QStringList themes; const QStringList &packs = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, "plasma/desktoptheme", QStandardPaths::LocateDirectory); foreach (const QString &ppath, packs) { const QDir cd(ppath); const QStringList &entries = cd.entryList(QDir::Dirs | QDir::Hidden); foreach (const QString pack, entries) { const QString _metadata = ppath+QLatin1Char('/')+pack+QStringLiteral("/metadata.desktop"); if ((pack != "." && pack != "..") && (QFile::exists(_metadata))) { themes << _metadata; } } } foreach (const QString &theme, themes) { int themeSepIndex = theme.lastIndexOf('/', -1); QString themeRoot = theme.left(themeSepIndex); int themeNameSepIndex = themeRoot.lastIndexOf('/', -1); QString packageName = themeRoot.right(themeRoot.length() - themeNameSepIndex - 1); KDesktopFile df(theme); if (df.noDisplay()) { continue; } QString name = df.readName(); if (name.isEmpty()) { name = packageName; } const QString comment = df.readComment(); const QString author = df.desktopGroup().readEntry("X-KDE-PluginInfo-Author",QString()); const QString version = df.desktopGroup().readEntry("X-KDE-PluginInfo-Version",QString()); ThemeInfo info; info.package = packageName; info.description = comment; info.author = author; info.version = version; info.themeRoot = themeRoot; m_themes[name] = info; }
void ThemeModel::reload() { reset(); clearThemeList(); // get all desktop themes QStringList themes = KGlobal::dirs()->findAllResources("data", "aurorae/themes/*/metadata.desktop", KStandardDirs::NoDuplicates); foreach(const QString &theme, themes) { int themeSepIndex = theme.lastIndexOf('/', -1); QString themeRoot = theme.left(themeSepIndex); int themeNameSepIndex = themeRoot.lastIndexOf('/', -1); QString packageName = themeRoot.right(themeRoot.length() - themeNameSepIndex - 1); KDesktopFile df(theme); QString name = df.readName(); if (name.isEmpty()) { name = packageName; } QString comment = df.readComment(); QString author = df.desktopGroup().readEntry("X-KDE-PluginInfo-Author", QString()); QString email = df.desktopGroup().readEntry("X-KDE-PluginInfo-Email", QString()); QString version = df.desktopGroup().readEntry("X-KDE-PluginInfo-Version", QString()); QString license = df.desktopGroup().readEntry("X-KDE-PluginInfo-License", QString()); QString website = df.desktopGroup().readEntry("X-KDE-PluginInfo-Website", QString()); Plasma::FrameSvg *svg = new Plasma::FrameSvg(this); QString svgFile = themeRoot + "/decoration.svg"; if (QFile::exists(svgFile)) { svg->setImagePath(svgFile); } else { svg->setImagePath(svgFile + 'z'); } svg->setEnabledBorders(Plasma::FrameSvg::AllBorders); ThemeConfig *config = new ThemeConfig(); KConfig conf("aurorae/themes/" + packageName + '/' + packageName + "rc", KConfig::FullConfig, "data"); config->load(&conf); // buttons QHash<QString, Plasma::FrameSvg*> *buttons = new QHash<QString, Plasma::FrameSvg*>(); initButtonFrame("minimize", packageName, buttons); initButtonFrame("maximize", packageName, buttons); initButtonFrame("restore", packageName, buttons); initButtonFrame("close", packageName, buttons); initButtonFrame("alldesktops", packageName, buttons); initButtonFrame("keepabove", packageName, buttons); initButtonFrame("keepbelow", packageName, buttons); initButtonFrame("shade", packageName, buttons); initButtonFrame("help", packageName, buttons); ThemeInfo info; info.package = packageName; info.description = comment; info.author = author; info.email = email; info.version = version; info.website = website; info.license = license; info.svg = svg; info.themeRoot = themeRoot; info.themeConfig = config; info.buttons = buttons; m_themes[name] = info; }
PlasmaThemeListModel::~PlasmaThemeListModel() { clearThemeList(); }
ThemeModel::~ThemeModel() { clearThemeList(); }