[plasmalnf] Make an actual job of setting the theme

- Job doesn't actually run lookandfeeltool in the target system yet.
This commit is contained in:
Adriaan de Groot 2017-12-03 09:26:59 -05:00
parent 2d3defcca3
commit 62623a2376
7 changed files with 35 additions and 58 deletions

View File

@ -8,6 +8,7 @@ calamares_add_plugin( plasmalnf
SOURCES
PlasmaLnfViewStep.cpp
PlasmaLnfPage.cpp
PlasmaLnfJob.cpp
PlasmaLnfInfo.cpp
UI
page_plasmalnf.ui

View File

@ -36,8 +36,8 @@
#include "utils/Logger.h"
PlasmaLnfJob::PlasmaLnfJob( QObject* parent )
: Calamares::CppJob( parent )
PlasmaLnfJob::PlasmaLnfJob( const QString& id )
: m_id(id)
{
}
@ -53,43 +53,15 @@ PlasmaLnfJob::prettyName() const
return tr( "Plasma Look-and-Feel Job" );
}
static void _themes_by_service()
QString
PlasmaLnfJob::prettyDescription() const
{
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;
return prettyName();
}
static void _themes_by_kcm()
QString PlasmaLnfJob::prettyStatusMessage() const
{
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();
return prettyName();
}
@ -98,17 +70,6 @@ PlasmaLnfJob::exec()
{
cDebug() << "Plasma Look-and-Feel Job";
_themes_by_service();
_themes_by_kcm();
return Calamares::JobResult::ok();
}
void
PlasmaLnfJob::setConfigurationMap( const QVariantMap& configurationMap )
{
m_configurationMap = configurationMap;
}
CALAMARES_PLUGIN_FACTORY_DEFINITION( PlasmaLnfJobFactory, registerPlugin<PlasmaLnfJob>(); )

View File

@ -22,30 +22,24 @@
#include <QObject>
#include <QVariantMap>
#include <CppJob.h>
#include <Job.h>
#include <utils/PluginFactory.h>
#include <PluginDllMacro.h>
class PLUGINDLLEXPORT PlasmaLnfJob : public Calamares::CppJob
class PlasmaLnfJob : public Calamares::Job
{
Q_OBJECT
public:
explicit PlasmaLnfJob( QObject* parent = nullptr );
explicit PlasmaLnfJob( const QString& id );
virtual ~PlasmaLnfJob() override;
QString prettyName() const override;
QString prettyDescription() const override;
QString prettyStatusMessage() const override;
Calamares::JobResult exec() override;
void setConfigurationMap( const QVariantMap& configurationMap ) override;
private:
QVariantMap m_configurationMap;
QString m_id;
};
CALAMARES_PLUGIN_FACTORY_DECLARATION( PlasmaLnfJobFactory )
#endif // PLASMALNFJOB_H

View File

@ -64,4 +64,7 @@ PlasmaLnfPage::activated(const QString& name)
; // OK
else
cDebug() << "WARNING: could not apply look-and-feel" << name;
emit plasmaThemeSelected( name );
}

View File

@ -36,6 +36,9 @@ public:
public slots:
void activated(const QString& name);
signals:
void plasmaThemeSelected( const QString &id );
private:
Ui::PlasmaLnfPage* ui;
};

View File

@ -35,6 +35,7 @@ PlasmaLnfViewStep::PlasmaLnfViewStep( QObject* parent )
: Calamares::ViewStep( parent )
, m_widget( new PlasmaLnfPage )
{
connect( m_widget, &PlasmaLnfPage::plasmaThemeSelected, this, &PlasmaLnfViewStep::themeSelected );
emit nextStatusChanged( false );
}
@ -111,6 +112,10 @@ PlasmaLnfViewStep::jobs() const
Calamares::JobList l;
cDebug() << "Creating Plasma LNF jobs ..";
if ( !m_themeId.isEmpty() )
{
l.append( Calamares::job_ptr( new PlasmaLnfJob( m_themeId ) ) );
}
return l;
}
@ -119,3 +124,9 @@ void
PlasmaLnfViewStep::setConfigurationMap( const QVariantMap& configurationMap )
{
}
void
PlasmaLnfViewStep::themeSelected( const QString& id )
{
m_themeId = id;
}

View File

@ -56,8 +56,12 @@ public:
void setConfigurationMap( const QVariantMap& configurationMap ) override;
public slots:
void themeSelected( const QString &id );
private:
PlasmaLnfPage* m_widget;
QString m_themeId;
};
CALAMARES_PLUGIN_FACTORY_DECLARATION( PlasmaLnfViewStepFactory )