[plasmalnf] Replace hard-coded path with configurable one

This commit is contained in:
Adriaan de Groot 2017-12-03 09:44:29 -05:00
parent 62623a2376
commit b3d299bbf1
7 changed files with 33 additions and 8 deletions

View File

@ -120,9 +120,21 @@ QStringList plasma_themes()
return l; return l;
} }
static QString *p_lnfPath = nullptr;
QString lnftool() QString lnftool()
{ {
return "/home/adridg/bin/lookandfeeltool"; if ( !p_lnfPath )
p_lnfPath = new QString("/usr/bin/lookandfeeltool");
return *p_lnfPath;
}
void set_lnftool( const QString& lnfPath )
{
if (p_lnfPath)
delete p_lnfPath;
p_lnfPath = new QString( lnfPath );
} }
} // namespace Calamares } // namespace Calamares

View File

@ -19,11 +19,13 @@
#ifndef PLASMALNFINFO_H #ifndef PLASMALNFINFO_H
#define PLASMALNFINFO_H #define PLASMALNFINFO_H
#include <QString>
#include <QStringList> #include <QStringList>
namespace Calamares namespace Calamares
{ {
QString lnftool(); QString lnftool();
void set_lnftool( const QString& );
/* Internal */ /* Internal */
QStringList themes_by_package(); QStringList themes_by_package();

View File

@ -36,8 +36,9 @@
#include "utils/Logger.h" #include "utils/Logger.h"
PlasmaLnfJob::PlasmaLnfJob( const QString& id ) PlasmaLnfJob::PlasmaLnfJob( const QString& lnfPath, const QString& id )
: m_id(id) : m_lnfPath( lnfPath )
, m_id(id)
{ {
} }

View File

@ -29,7 +29,7 @@ class PlasmaLnfJob : public Calamares::Job
Q_OBJECT Q_OBJECT
public: public:
explicit PlasmaLnfJob( const QString& id ); explicit PlasmaLnfJob( const QString& lnfPath, const QString& id );
virtual ~PlasmaLnfJob() override; virtual ~PlasmaLnfJob() override;
QString prettyName() const override; QString prettyName() const override;
@ -39,6 +39,7 @@ public:
Calamares::JobResult exec() override; Calamares::JobResult exec() override;
private: private:
QString m_lnfPath;
QString m_id; QString m_id;
}; };

View File

@ -22,6 +22,7 @@
#include "utils/CalamaresUtils.h" #include "utils/CalamaresUtils.h"
#include "utils/CalamaresUtilsSystem.h" #include "utils/CalamaresUtilsSystem.h"
#include "PlasmaLnfInfo.h"
#include "PlasmaLnfJob.h" #include "PlasmaLnfJob.h"
#include "PlasmaLnfPage.h" #include "PlasmaLnfPage.h"
#include "PlasmaLnfViewStep.h" #include "PlasmaLnfViewStep.h"
@ -112,9 +113,9 @@ PlasmaLnfViewStep::jobs() const
Calamares::JobList l; Calamares::JobList l;
cDebug() << "Creating Plasma LNF jobs .."; cDebug() << "Creating Plasma LNF jobs ..";
if ( !m_themeId.isEmpty() ) if ( !m_themeId.isEmpty() && !m_lnfPath.isEmpty() )
{ {
l.append( Calamares::job_ptr( new PlasmaLnfJob( m_themeId ) ) ); l.append( Calamares::job_ptr( new PlasmaLnfJob( m_lnfPath, m_themeId ) ) );
} }
return l; return l;
} }
@ -123,6 +124,11 @@ PlasmaLnfViewStep::jobs() const
void void
PlasmaLnfViewStep::setConfigurationMap( const QVariantMap& configurationMap ) PlasmaLnfViewStep::setConfigurationMap( const QVariantMap& configurationMap )
{ {
m_lnfPath = CalamaresUtils::getString( configurationMap, "lnftool" );
Calamares::set_lnftool( m_lnfPath );
if (m_lnfPath.isEmpty())
cDebug() << "WARNING: no lnftool given for plasmalnf module.";
} }
void void

View File

@ -61,6 +61,7 @@ public slots:
private: private:
PlasmaLnfPage* m_widget; PlasmaLnfPage* m_widget;
QString m_lnfPath;
QString m_themeId; QString m_themeId;
}; };

View File

@ -1,2 +1,4 @@
-- ---
# PlasmaLnf module has no configuration # Full path to the Plasma look-and-feel tool (CLI program
# for querying and applying Plasma themes).
lnftool: "/usr/bin/lookandfeeltool"