From ecba1f6d3b3d243fc35a0fd8ba5316e6283b653f Mon Sep 17 00:00:00 2001 From: Aaron Seigo Date: Tue, 26 Apr 2011 20:53:51 +0200 Subject: [PATCH 1/2] do all three types nicely --- tools/plasmapkg/main.cpp | 98 ++++++++++++++++++++++------------------ 1 file changed, 55 insertions(+), 43 deletions(-) diff --git a/tools/plasmapkg/main.cpp b/tools/plasmapkg/main.cpp index d65995f22..b4241eceb 100644 --- a/tools/plasmapkg/main.cpp +++ b/tools/plasmapkg/main.cpp @@ -75,28 +75,67 @@ void listPackages(const QStringList& types) } } +void renderTypeTable(const QMap &plugins) +{ + const QString nameHeader = i18n("Addon Name"); + const QString pluginHeader = i18n("Service Type"); + const QString pathHeader = i18n("Path"); + int nameWidth = nameHeader.length(); + int pluginWidth = pluginHeader.length(); + int pathWidth = pathHeader.length(); + + QMapIterator pluginIt(plugins); + while (pluginIt.hasNext()) { + pluginIt.next(); + if (pluginIt.key().length() > nameWidth) { + nameWidth = pluginIt.key().length(); + } + + if (pluginIt.value()[0].length() > pluginWidth) { + pluginWidth = pluginIt.value()[0].length(); + } + + if (pluginIt.value()[1].length() > pathWidth) { + pathWidth = pluginIt.value()[1].length(); + } + } + + std::cout << nameHeader.toLocal8Bit().constData() << std::setw(nameWidth - nameHeader.length() + 2) << ' ' + << pluginHeader.toLocal8Bit().constData() << std::setw(pluginWidth - pluginHeader.length() + 2) << ' ' + << pathHeader.toLocal8Bit().constData() << std::endl; + std::cout << std::setfill('-') << std::setw(nameWidth) << '-' << " " + << std::setw(pluginWidth) << '-' << " " + << std::setw(pathWidth) << '-' << std::endl; + std::cout << std::setfill(' '); + + pluginIt.toFront(); + while (pluginIt.hasNext()) { + pluginIt.next(); + std::cout << pluginIt.key().toLocal8Bit().constData() << std::setw(nameWidth - pluginIt.key().length() + 2) << ' ' + << pluginIt.value()[0].toLocal8Bit().constData() << std::setw(pluginWidth - pluginIt.value()[0].length() + 2) << ' ' + << pluginIt.value()[1].toLocal8Bit().constData() << std::endl; + } +} + void listTypes() { output(i18n("Package types that are installable with this tool:")); output(i18n("Built in:")); - output(i18n(" dataengine: Plasma DataEngine plugin")); - 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")); + + QMap 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:")); - 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 pathWidth = pathHeader.length(); QMap plugins; foreach (const KService::Ptr service, offers) { @@ -105,51 +144,24 @@ void listTypes() QString name = info.name(); QString plugin = info.pluginName(); QString path = structure->defaultPackageRoot(); - - if (name.length() > nameWidth) { - nameWidth = name.length(); - } - - if (plugin.length() > pluginWidth) { - pluginWidth = plugin.length(); - } - - if (path.length() > pathWidth) { - pathWidth = path.length(); - } - plugins.insert(name, QStringList() << plugin << path); } - - std::cout << nameHeader.toLocal8Bit().constData() << std::setw(nameWidth - nameHeader.length() + 2) << ' ' - << pluginHeader.toLocal8Bit().constData() << std::setw(pluginWidth - pluginHeader.length() + 2) << ' ' - << pathHeader.toLocal8Bit().constData() << std::endl; - std::cout << std::setfill('-') << std::setw(nameWidth) << '-' << " " - << std::setw(pluginWidth) << '-' << " " - << std::setw(pathWidth) << '-' << std::endl; - QMapIterator pluginIt(plugins); - std::cout << std::setfill(' '); - while (pluginIt.hasNext()) { - pluginIt.next(); - std::cout << pluginIt.key().toLocal8Bit().constData() << std::setw(nameWidth - pluginIt.key().length() + 2) << ' ' - << pluginIt.value()[0].toLocal8Bit().constData() << std::setw(pluginWidth - pluginIt.value()[0].length() + 2) << ' ' - << pluginIt.value()[1].toLocal8Bit().constData() << std::endl; - } + renderTypeTable(plugins); } QStringList desktopFiles = KGlobal::dirs()->findAllResources("data", "plasma/packageformats/*rc", KStandardDirs::NoDuplicates); if (!desktopFiles.isEmpty()) { output(i18n("Provided by .desktop files:")); Plasma::PackageStructure structure; + QMap plugins; foreach (const QString &file, desktopFiles) { // extract the type KConfig config(file, KConfig::SimpleConfig); structure.read(&config); // get the name based on the rc file name, just as Plasma::PackageStructure does 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", - " %1: %2", name, structure.type())); + plugins.insert(name, QStringList() << structure.type() << structure.defaultPackageRoot()); } } } From 3dbe535deca66f2d4241cd4ef69daaa05cd9ed03 Mon Sep 17 00:00:00 2001 From: Artur Duque de Souza Date: Tue, 26 Apr 2011 16:46:14 -0300 Subject: [PATCH 2/2] Last bits to theme bindings We are going to need a proxy for the theme anyway, so we need this guy complete anyway. Let's forget about the idea of exporting Plasma::Theme directly. Signed-off-by: Artur Duque de Souza --- declarativeimports/core/theme.cpp | 19 +++++++++++++++++-- declarativeimports/core/theme_p.h | 18 ++++++++++++------ 2 files changed, 29 insertions(+), 8 deletions(-) diff --git a/declarativeimports/core/theme.cpp b/declarativeimports/core/theme.cpp index 0735a9c89..1e640d1b2 100644 --- a/declarativeimports/core/theme.cpp +++ b/declarativeimports/core/theme.cpp @@ -31,7 +31,7 @@ ThemeProxy::~ThemeProxy() { } -QString ThemeProxy::name() const +QString ThemeProxy::themeName() const { return Plasma::Theme::defaultTheme()->themeName(); } @@ -46,11 +46,26 @@ bool ThemeProxy::windowTranslucencyEnabled() const return Plasma::Theme::defaultTheme()->windowTranslucencyEnabled(); } -QUrl ThemeProxy::homepage() const +KUrl ThemeProxy::homepage() const { return Plasma::Theme::defaultTheme()->homepage(); } +bool ThemeProxy::useGlobalSettings() const +{ + return Plasma::Theme::defaultTheme()->useGlobalSettings(); +} + +QString ThemeProxy::styleSheet() const +{ + return Plasma::Theme::defaultTheme()->styleSheet(); +} + +QString ThemeProxy::wallpaperPath() const +{ + return Plasma::Theme::defaultTheme()->wallpaperPath(); +} + QColor ThemeProxy::textColor() const { return Plasma::Theme::defaultTheme()->color(Plasma::Theme::TextColor); diff --git a/declarativeimports/core/theme_p.h b/declarativeimports/core/theme_p.h index e2a86612c..820df1da5 100644 --- a/declarativeimports/core/theme_p.h +++ b/declarativeimports/core/theme_p.h @@ -21,7 +21,7 @@ #include -#include +#include #include #include @@ -29,10 +29,13 @@ class ThemeProxy : public QObject { Q_OBJECT - Q_PROPERTY(QString name READ name NOTIFY themeChanged) + Q_PROPERTY(QString themeName READ themeName NOTIFY themeChanged) Q_PROPERTY(QFont font READ font NOTIFY themeChanged) - Q_PROPERTY(bool translucent READ windowTranslucencyEnabled NOTIFY themeChanged) - Q_PROPERTY(QUrl homepage READ homepage NOTIFY themeChanged) + Q_PROPERTY(bool windowTranslucentEnabled READ windowTranslucencyEnabled NOTIFY themeChanged) + Q_PROPERTY(KUrl homepage READ homepage NOTIFY themeChanged) + Q_PROPERTY(bool useGlobalSettings READ useGlobalSettings NOTIFY themeChanged) + Q_PROPERTY(QString styleSheet READ styleSheet NOTIFY themeChanged) + Q_PROPERTY(QString wallpaperPath READ wallpaperPath NOTIFY themeChanged) // colors Q_PROPERTY(QColor textColor READ textColor NOTIFY themeChanged) @@ -54,10 +57,13 @@ public: ThemeProxy(QObject *parent = 0); ~ThemeProxy(); - QString name() const; + QString themeName() const; QFont font() const; bool windowTranslucencyEnabled() const; - QUrl homepage() const; + KUrl homepage() const; + bool useGlobalSettings() const; + QString styleSheet() const; + QString wallpaperPath() const; QColor textColor() const; QColor highlightColor() const;