//------------------------------------------------------------------------- void PluginRegistry::selectPlugin( AbstractPlugin* plugin ) { AbstractPlugin* selectedPlugin( getSelectedPlugin() ); if( plugin == selectedPlugin ) { return; } if( selectedPlugin != nullptr ) { selectedPlugin->close(); } // reset camera and selected vehicle Camera::accessInstance().reset (); SteeringVehicle::setSelectedVehicle( nullptr ); setSelectedPlugin( plugin ); if( getSelectedPlugin() != nullptr ) { getSelectedPlugin()->prepareOpen(); // note: call the application // might initialize the gui if( _on_plugin_selected_func != nullptr ) { _on_plugin_selected_func( getSelectedPlugin() ); } getSelectedPlugin()->open(); } }
void KCMLookandFeel::defaults() { if (!m_package.metadata().isValid()) { return; } setSelectedPlugin(m_package.metadata().pluginName()); }
// Update plugin choice from current filename FilePluginInterface* FileSelectorWidget::updatePluginFromCurrentFilename() { if (refreshing_ || (selectedFilenames_.count() == 0)) return NULL; // Loop over FilterCombo items, which contain pointers to the associated FilePluginInterfaces for (int n=0; n<ui.FilterCombo->count(); ++n) { RefListItem<FilePluginInterface,KVMap>* refItem = (RefListItem<FilePluginInterface,KVMap>*) VariantPointer< RefListItem<FilePluginInterface,KVMap> >(ui.FilterCombo->itemData(n)); if (!refItem) continue; FilePluginInterface* plugin = refItem->item; if (plugin->isRelatedToFile(selectedFilenames_.first())) { setSelectedPlugin(plugin); return plugin; } } return NULL; }
void KCMLookandFeel::load() { m_package = Plasma::PluginLoader::self()->loadPackage(QStringLiteral("Plasma/LookAndFeel")); KConfigGroup cg(KSharedConfig::openConfig(QStringLiteral("kdeglobals")), "KDE"); const QString packageName = cg.readEntry("LookAndFeelPackage", QString()); if (!packageName.isEmpty()) { m_package.setPath(packageName); } if (!m_package.metadata().isValid()) { return; } setSelectedPlugin(m_package.metadata().pluginName()); m_model->clear(); const QList<Plasma::Package> pkgs = availablePackages(); for (const Plasma::Package &pkg : pkgs) { if (!pkg.metadata().isValid()) { continue; } QStandardItem* row = new QStandardItem(pkg.metadata().name()); row->setData(pkg.metadata().pluginName(), PluginNameRole); row->setData(pkg.filePath("previews", QStringLiteral("preview.png")), ScreenhotRole); //What the package provides row->setData(!pkg.filePath("splashmainscript").isEmpty(), HasSplashRole); row->setData(!pkg.filePath("lockscreenmainscript").isEmpty(), HasLockScreenRole); row->setData(!pkg.filePath("runcommandmainscript").isEmpty(), HasRunCommandRole); row->setData(!pkg.filePath("logoutmainscript").isEmpty(), HasLogoutRole); if (!pkg.filePath("defaults").isEmpty()) { KSharedConfigPtr conf = KSharedConfig::openConfig(pkg.filePath("defaults")); KConfigGroup cg(conf, "kdeglobals"); cg = KConfigGroup(&cg, "General"); bool hasColors = !cg.readEntry("ColorScheme", QString()).isEmpty(); row->setData(hasColors, HasColorsRole); if (!hasColors) { hasColors = !pkg.filePath("colors").isEmpty(); } cg = KConfigGroup(&cg, "KDE"); row->setData(!cg.readEntry("widgetStyle", QString()).isEmpty(), HasWidgetStyleRole); cg = KConfigGroup(conf, "kdeglobals"); cg = KConfigGroup(&cg, "Icons"); row->setData(!cg.readEntry("Theme", QString()).isEmpty(), HasIconsRole); cg = KConfigGroup(conf, "kdeglobals"); cg = KConfigGroup(&cg, "Theme"); row->setData(!cg.readEntry("name", QString()).isEmpty(), HasPlasmaThemeRole); cg = KConfigGroup(conf, "kcminputrc"); cg = KConfigGroup(&cg, "Mouse"); row->setData(!cg.readEntry("cursorTheme", QString()).isEmpty(), HasCursorsRole); cg = KConfigGroup(conf, "kwinrc"); cg = KConfigGroup(&cg, "WindowSwitcher"); row->setData(!cg.readEntry("LayoutName", QString()).isEmpty(), HasWindowSwitcherRole); cg = KConfigGroup(conf, "kwinrc"); cg = KConfigGroup(&cg, "DesktopSwitcher"); row->setData(!cg.readEntry("LayoutName", QString()).isEmpty(), HasDesktopSwitcherRole); } m_model->appendRow(row); } }