[kcmkwin/tabbox] Find all layouts in lnf package

First try to locate all look-and-feel packages and check whether
they provide a WindowSwitcher. If they do they are inserted in
the list with the Package name being the user visible name.
So the good old sidebar is now called "Breeze".

REVIEW: 120914
This commit is contained in:
Martin Gräßlin 2014-10-31 12:53:42 +01:00
parent 0f7a990316
commit 26cf3195be
2 changed files with 43 additions and 0 deletions

View file

@ -26,6 +26,7 @@ target_link_libraries(kcm_kwintabbox
KF5::I18n
KF5::Service
KF5::NewStuff
KF5::Plasma
XCB::XCB
kwin4_effect_builtins
)

View file

@ -42,6 +42,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <KServiceTypeTrader>
#include <KShortcutsEditor>
#include <KNewStuff3/KNS3/DownloadDialog>
// Plasma
#include <Plasma/Package>
#include <Plasma/PluginLoader>
// own
#include "tabboxconfig.h"
@ -158,6 +161,36 @@ KWinTabBoxConfig::~KWinTabBoxConfig()
{
}
static QList<Plasma::Package> availableLnFPackages()
{
QList<Plasma::Package> packages;
QStringList paths;
const QStringList dataPaths = QStandardPaths::standardLocations(QStandardPaths::GenericDataLocation);
for (const QString &path : dataPaths) {
QDir dir(path + QStringLiteral("/plasma/look-and-feel"));
paths << dir.entryList(QDir::AllDirs | QDir::NoDotAndDotDot);
}
const auto &p = paths;
for (const QString &path : p) {
Plasma::Package pkg = Plasma::PluginLoader::self()->loadPackage(QStringLiteral("Plasma/LookAndFeel"));
pkg.setPath(path);
pkg.setFallbackPackage(Plasma::Package());
if (!pkg.filePath("defaults").isEmpty()) {
KSharedConfigPtr conf = KSharedConfig::openConfig(pkg.filePath("defaults"));
KConfigGroup cg = KConfigGroup(conf, "kwinrc");
cg = KConfigGroup(&cg, "WindowSwitcher");
if (!cg.readEntry("LayoutName", QString()).isEmpty()) {
packages << pkg;
}
}
}
return packages;
}
void KWinTabBoxConfig::initLayoutLists()
{
// search the effect names
@ -167,6 +200,15 @@ void KWinTabBoxConfig::initLayoutLists()
KServiceTypeTrader* trader = KServiceTypeTrader::self();
KService::List offers = trader->query("KWin/WindowSwitcher");
QStringList layoutNames, layoutPlugins, layoutPaths;
const auto lnfPackages = availableLnFPackages();
for (const auto &package : lnfPackages) {
const auto &metaData = package.metadata();
layoutNames << metaData.name();
layoutPlugins << metaData.pluginName();
layoutPaths << package.filePath("windowswitcher", QStringLiteral("WindowSwitcher.qml"));
}
foreach (KService::Ptr service, offers) {
const QString pluginName = service->property("X-KDE-PluginInfo-Name").toString();
if (service->property("X-Plasma-API").toString() != "declarativeappletscript") {