[plasmalnf] Search for LNF themes like the KCM does

main
Adriaan de Groot 7 years ago
parent 6c873f0b70
commit 41e8fdd362

@ -1,6 +1,6 @@
find_package(ECM ${ECM_VERSION} REQUIRED NO_MODULE)
find_package( KF5 REQUIRED CoreAddons Service )
find_package( KF5 5.29 REQUIRED CoreAddons Plasma Service )
calamares_add_plugin( plasmalnf
TYPE job
@ -9,5 +9,7 @@ calamares_add_plugin( plasmalnf
PlasmaLnfJob.cpp
LINK_PRIVATE_LIBRARIES
calamares
KF5::Plasma
KF5::Service
SHARED_LIB
)

@ -18,10 +18,18 @@
#include "PlasmaLnfJob.h"
#include <QProcess>
#include <QDateTime>
#include <QDir>
#include <QProcess>
#include <QStandardPaths>
#include <QThread>
#include <KService>
#include <KServiceTypeTrader>
#include <KPluginLoader> // Future
#include <Plasma/PluginLoader> // TODO: port to KPluginLoader
#include "CalamaresVersion.h"
#include "JobQueue.h"
#include "GlobalStorage.h"
@ -45,12 +53,54 @@ PlasmaLnfJob::prettyName() const
return tr( "Plasma Look-and-Feel Job" );
}
static void _themes_by_service()
{
KService::List services;
KServiceTypeTrader* trader = KServiceTypeTrader::self();
services = trader->query("Plasma/Theme");
int c = 0;
for ( const auto s : services )
{
cDebug() << "Plasma theme '" << s->name() << '\'';
c++;
}
cDebug() << "Plasma themes by service found" << c;
}
static void _themes_by_kcm()
{
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;
cDebug() << "Plasma theme '" << pkg.metadata().pluginName() << '\'';
}
}
cDebug() << "Plasma themes by kcm found" << packages.length();
}
Calamares::JobResult
PlasmaLnfJob::exec()
{
cDebug() << "Plasma Look-and-Feel Job";
_themes_by_service();
_themes_by_kcm();
return Calamares::JobResult::ok();
}

Loading…
Cancel
Save