do all three types nicely
This commit is contained in:
parent
5364a3bd50
commit
ecba1f6d3b
@ -75,61 +75,40 @@ void listPackages(const QStringList& types)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void listTypes()
|
void renderTypeTable(const QMap<QString, QStringList> &plugins)
|
||||||
{
|
{
|
||||||
output(i18n("Package types that are installable with this tool:"));
|
const QString nameHeader = i18n("Addon Name");
|
||||||
output(i18n("Built in:"));
|
const QString pluginHeader = i18n("Service Type");
|
||||||
output(i18n(" dataengine: Plasma DataEngine plugin"));
|
const QString pathHeader = i18n("Path");
|
||||||
output(i18n(" layout-template: Plasma containment and widget layout script"));
|
|
||||||
output(i18n(" plasmoid: Plasma widget"));
|
|
||||||
output(i18n(" runner: Search plugin (KRunner, etc)"));
|
|
||||||
output(i18n(" theme: Plasma SVG theme"));
|
|
||||||
output(i18n(" wallpaper: Image pack for use with wallpaper backgrounds"));
|
|
||||||
output(i18n(" wallpaperplugin: Wallpaper plugin"));
|
|
||||||
|
|
||||||
KService::List offers = KServiceTypeTrader::self()->query("Plasma/PackageStructure");
|
|
||||||
if (!offers.isEmpty()) {
|
|
||||||
std::cout << std::endl;
|
|
||||||
output(i18n("Provided by plugins:"));
|
|
||||||
const QString pluginHeader = i18n("Plugin Name");
|
|
||||||
const QString nameHeader = i18n("Type");
|
|
||||||
const QString pathHeader = i18n("Install Root");
|
|
||||||
int pluginWidth = pluginHeader.length();
|
|
||||||
int nameWidth = nameHeader.length();
|
int nameWidth = nameHeader.length();
|
||||||
|
int pluginWidth = pluginHeader.length();
|
||||||
int pathWidth = pathHeader.length();
|
int pathWidth = pathHeader.length();
|
||||||
|
|
||||||
QMap<QString, QStringList> plugins;
|
QMapIterator<QString, QStringList> pluginIt(plugins);
|
||||||
foreach (const KService::Ptr service, offers) {
|
while (pluginIt.hasNext()) {
|
||||||
KPluginInfo info(service);
|
pluginIt.next();
|
||||||
Plasma::PackageStructure::Ptr structure = Plasma::PackageStructure::load(info.pluginName());
|
if (pluginIt.key().length() > nameWidth) {
|
||||||
QString name = info.name();
|
nameWidth = pluginIt.key().length();
|
||||||
QString plugin = info.pluginName();
|
|
||||||
QString path = structure->defaultPackageRoot();
|
|
||||||
|
|
||||||
if (name.length() > nameWidth) {
|
|
||||||
nameWidth = name.length();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (plugin.length() > pluginWidth) {
|
if (pluginIt.value()[0].length() > pluginWidth) {
|
||||||
pluginWidth = plugin.length();
|
pluginWidth = pluginIt.value()[0].length();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (path.length() > pathWidth) {
|
if (pluginIt.value()[1].length() > pathWidth) {
|
||||||
pathWidth = path.length();
|
pathWidth = pluginIt.value()[1].length();
|
||||||
}
|
}
|
||||||
|
|
||||||
plugins.insert(name, QStringList() << plugin << path);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::cout << nameHeader.toLocal8Bit().constData() << std::setw(nameWidth - nameHeader.length() + 2) << ' '
|
std::cout << nameHeader.toLocal8Bit().constData() << std::setw(nameWidth - nameHeader.length() + 2) << ' '
|
||||||
<< pluginHeader.toLocal8Bit().constData() << std::setw(pluginWidth - pluginHeader.length() + 2) << ' '
|
<< pluginHeader.toLocal8Bit().constData() << std::setw(pluginWidth - pluginHeader.length() + 2) << ' '
|
||||||
<< pathHeader.toLocal8Bit().constData() << std::endl;
|
<< pathHeader.toLocal8Bit().constData() << std::endl;
|
||||||
std::cout << std::setfill('-') << std::setw(nameWidth) << '-' << " "
|
std::cout << std::setfill('-') << std::setw(nameWidth) << '-' << " "
|
||||||
<< std::setw(pluginWidth) << '-' << " "
|
<< std::setw(pluginWidth) << '-' << " "
|
||||||
<< std::setw(pathWidth) << '-' << std::endl;
|
<< std::setw(pathWidth) << '-' << std::endl;
|
||||||
QMapIterator<QString, QStringList> pluginIt(plugins);
|
|
||||||
std::cout << std::setfill(' ');
|
std::cout << std::setfill(' ');
|
||||||
|
|
||||||
|
pluginIt.toFront();
|
||||||
while (pluginIt.hasNext()) {
|
while (pluginIt.hasNext()) {
|
||||||
pluginIt.next();
|
pluginIt.next();
|
||||||
std::cout << pluginIt.key().toLocal8Bit().constData() << std::setw(nameWidth - pluginIt.key().length() + 2) << ' '
|
std::cout << pluginIt.key().toLocal8Bit().constData() << std::setw(nameWidth - pluginIt.key().length() + 2) << ' '
|
||||||
@ -138,18 +117,51 @@ void listTypes()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void listTypes()
|
||||||
|
{
|
||||||
|
output(i18n("Package types that are installable with this tool:"));
|
||||||
|
output(i18n("Built in:"));
|
||||||
|
|
||||||
|
QMap<QString, QStringList> builtIns;
|
||||||
|
builtIns.insert(i18n("DataEngine"), QStringList() << "Plasma/DataEngine" << "plasma/dataengines/");
|
||||||
|
builtIns.insert(i18n("Layout Template"), QStringList() << "Plasma/LayoutTemplate" << "plasma/layout-templates/");
|
||||||
|
builtIns.insert(i18n("Plasmoid"), QStringList() << "Plasma/Applet" << "plasma/plasmoids/");
|
||||||
|
builtIns.insert(i18n("Runner"), QStringList() << "Plasma/Runner" << "plasma/runners/");
|
||||||
|
builtIns.insert(i18n("Theme"), QStringList() << "" << "desktoptheme/");
|
||||||
|
builtIns.insert(i18n("Wallpaper Images"), QStringList() << "" << "wallpapers/");
|
||||||
|
builtIns.insert(i18n("Wallpaper Plugin"), QStringList() << "Plasma/Wallpaper" << "plasma/wallpapers/");
|
||||||
|
renderTypeTable(builtIns);
|
||||||
|
|
||||||
|
KService::List offers = KServiceTypeTrader::self()->query("Plasma/PackageStructure");
|
||||||
|
if (!offers.isEmpty()) {
|
||||||
|
std::cout << std::endl;
|
||||||
|
output(i18n("Provided by plugins:"));
|
||||||
|
|
||||||
|
QMap<QString, QStringList> plugins;
|
||||||
|
foreach (const KService::Ptr service, offers) {
|
||||||
|
KPluginInfo info(service);
|
||||||
|
Plasma::PackageStructure::Ptr structure = Plasma::PackageStructure::load(info.pluginName());
|
||||||
|
QString name = info.name();
|
||||||
|
QString plugin = info.pluginName();
|
||||||
|
QString path = structure->defaultPackageRoot();
|
||||||
|
plugins.insert(name, QStringList() << plugin << path);
|
||||||
|
}
|
||||||
|
|
||||||
|
renderTypeTable(plugins);
|
||||||
|
}
|
||||||
|
|
||||||
QStringList desktopFiles = KGlobal::dirs()->findAllResources("data", "plasma/packageformats/*rc", KStandardDirs::NoDuplicates);
|
QStringList desktopFiles = KGlobal::dirs()->findAllResources("data", "plasma/packageformats/*rc", KStandardDirs::NoDuplicates);
|
||||||
if (!desktopFiles.isEmpty()) {
|
if (!desktopFiles.isEmpty()) {
|
||||||
output(i18n("Provided by .desktop files:"));
|
output(i18n("Provided by .desktop files:"));
|
||||||
Plasma::PackageStructure structure;
|
Plasma::PackageStructure structure;
|
||||||
|
QMap<QString, QStringList> plugins;
|
||||||
foreach (const QString &file, desktopFiles) {
|
foreach (const QString &file, desktopFiles) {
|
||||||
// extract the type
|
// extract the type
|
||||||
KConfig config(file, KConfig::SimpleConfig);
|
KConfig config(file, KConfig::SimpleConfig);
|
||||||
structure.read(&config);
|
structure.read(&config);
|
||||||
// get the name based on the rc file name, just as Plasma::PackageStructure does
|
// get the name based on the rc file name, just as Plasma::PackageStructure does
|
||||||
const QString name = file.left(file.length() - 2);
|
const QString name = file.left(file.length() - 2);
|
||||||
output(i18nc("Plugin name and the kind of Plasma related content it provides, both from the plugin's desktop file",
|
plugins.insert(name, QStringList() << structure.type() << structure.defaultPackageRoot());
|
||||||
" %1: %2", name, structure.type()));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user