QString MediaBrowserLoader::getMediaBrowser(const QString &pluginName) const { Plasma::Package package = Plasma::PluginLoader::self()->loadPackage("Plasma/Generic"); package.setPath(pluginName); if(!package.isValid() || !package.metadata().isValid()) { package.setPath("invalidbrowser"); } QUrl filePath = QUrl::fromLocalFile(package.filePath("mainscript")); return filePath.toString(); }
QList<Plasma::Package> KCMLookandFeel::availablePackages(const QString &component) { QList<Plasma::Package> packages; QStringList paths; const QStringList dataPaths = QStandardPaths::standardLocations(QStandardPaths::GenericDataLocation); for (const QString &path : dataPaths) { QDir dir(path + "/plasma/look-and-feel"); paths << dir.entryList(QDir::AllDirs | QDir::NoDotAndDotDot); } for (const QString &path : paths) { Plasma::Package pkg = Plasma::PluginLoader::self()->loadPackage(QStringLiteral("Plasma/LookAndFeel")); pkg.setPath(path); pkg.setFallbackPackage(Plasma::Package()); if (component.isEmpty() || !pkg.filePath(component.toUtf8()).isEmpty()) { packages << pkg; } } return packages; }
void KCMLookandFeel::save() { Plasma::Package package = Plasma::PluginLoader::self()->loadPackage(QStringLiteral("Plasma/LookAndFeel")); package.setPath(m_selectedPlugin); if (!package.isValid()) { return; } m_configGroup.writeEntry("LookAndFeelPackage", m_selectedPlugin); if (!package.filePath("defaults").isEmpty()) { KSharedConfigPtr conf = KSharedConfig::openConfig(package.filePath("defaults")); KConfigGroup cg(conf, "kdeglobals"); cg = KConfigGroup(&cg, "KDE"); if (m_applyWidgetStyle) { setWidgetStyle(cg.readEntry("widgetStyle", QString())); } if (m_applyColors) { QString colorsFile = package.filePath("colors"); KConfigGroup cg(conf, "kdeglobals"); cg = KConfigGroup(&cg, "General"); QString colorScheme = cg.readEntry("ColorScheme", QString()); if (!colorsFile.isEmpty()) { if (!colorScheme.isEmpty()) { setColors(colorScheme, colorsFile); } else { setColors(package.metadata().name(), colorsFile); } } else if (!colorScheme.isEmpty()) { colorScheme.remove('\''); // So Foo's does not become FooS QRegExp fixer(QStringLiteral("[\\W,.-]+(.?)")); int offset; while ((offset = fixer.indexIn(colorScheme)) >= 0) { colorScheme.replace(offset, fixer.matchedLength(), fixer.cap(1).toUpper()); } colorScheme.replace(0, 1, colorScheme.at(0).toUpper()); QString src = QStandardPaths::locate(QStandardPaths::GenericDataLocation, "color-schemes/" + colorScheme + ".colors"); setColors(colorScheme, src); } } if (m_applyIcons) { cg = KConfigGroup(conf, "kdeglobals"); cg = KConfigGroup(&cg, "Icons"); setIcons(cg.readEntry("Theme", QString())); } if (m_applyPlasmaTheme) { cg = KConfigGroup(conf, "plasmarc"); cg = KConfigGroup(&cg, "Theme"); setPlasmaTheme(cg.readEntry("name", QString())); } if (m_applyCursors) { cg = KConfigGroup(conf, "kcminputrc"); cg = KConfigGroup(&cg, "Mouse"); setCursorTheme(cg.readEntry("cursorTheme", QString())); } if (m_applyWindowSwitcher) { cg = KConfigGroup(conf, "kwinrc"); cg = KConfigGroup(&cg, "WindowSwitcher"); setWindowSwitcher(cg.readEntry("LayoutName", QString())); } if (m_applyDesktopSwitcher) { cg = KConfigGroup(conf, "kwinrc"); cg = KConfigGroup(&cg, "DesktopSwitcher"); setDesktopSwitcher(cg.readEntry("LayoutName", QString())); } } //TODO: option to enable/disable apply? they don't seem required by UI design setSplashScreen(m_selectedPlugin); setLockScreen(m_selectedPlugin); m_configGroup.sync(); runRdb(KRdbExportQtColors | KRdbExportGtkTheme | KRdbExportColors | KRdbExportQtSettings | KRdbExportXftSettings); }