From 00293d11118112b69c3f45cee615ec9600e4e261 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Wed, 11 Nov 2020 13:21:16 +0100 Subject: [PATCH] [plasmalnf] Move the lookandfeeltool path setting to Config --- src/modules/plasmalnf/Config.cpp | 11 ++++++++++- src/modules/plasmalnf/Config.h | 5 +++++ src/modules/plasmalnf/PlasmaLnfViewStep.cpp | 21 ++++++++------------- src/modules/plasmalnf/PlasmaLnfViewStep.h | 1 - 4 files changed, 23 insertions(+), 15 deletions(-) diff --git a/src/modules/plasmalnf/Config.cpp b/src/modules/plasmalnf/Config.cpp index 6a80509f4..cefbd1e64 100644 --- a/src/modules/plasmalnf/Config.cpp +++ b/src/modules/plasmalnf/Config.cpp @@ -9,12 +9,21 @@ #include "Config.h" +#include "utils/Logger.h" +#include "utils/Variant.h" + Config::Config( QObject* parent ) : QObject( parent ) { } void -Config::setConfigurationMap( const QVariantMap& ) +Config::setConfigurationMap( const QVariantMap& configurationMap ) { + m_lnfPath = CalamaresUtils::getString( configurationMap, "lnftool" ); + + if ( m_lnfPath.isEmpty() ) + { + cWarning() << "no lnftool given for plasmalnf module."; + } } diff --git a/src/modules/plasmalnf/Config.h b/src/modules/plasmalnf/Config.h index 389e2aff4..759d9677f 100644 --- a/src/modules/plasmalnf/Config.h +++ b/src/modules/plasmalnf/Config.h @@ -21,6 +21,11 @@ public: virtual ~Config() override = default; void setConfigurationMap( const QVariantMap& ); + + QString lnfToolPath() const { return m_lnfPath; } + +private: + QString m_lnfPath; // Path to the lnf tool }; #endif diff --git a/src/modules/plasmalnf/PlasmaLnfViewStep.cpp b/src/modules/plasmalnf/PlasmaLnfViewStep.cpp index 971805502..1e894011b 100644 --- a/src/modules/plasmalnf/PlasmaLnfViewStep.cpp +++ b/src/modules/plasmalnf/PlasmaLnfViewStep.cpp @@ -113,9 +113,9 @@ PlasmaLnfViewStep::jobs() const cDebug() << "Creating Plasma LNF jobs .."; if ( !m_themeId.isEmpty() ) { - if ( !m_lnfPath.isEmpty() ) + if ( !m_config->lnfToolPath().isEmpty() ) { - l.append( Calamares::job_ptr( new PlasmaLnfJob( m_lnfPath, m_themeId ) ) ); + l.append( Calamares::job_ptr( new PlasmaLnfJob( m_config->lnfToolPath(), m_themeId ) ) ); } else { @@ -130,13 +130,8 @@ void PlasmaLnfViewStep::setConfigurationMap( const QVariantMap& configurationMap ) { m_config->setConfigurationMap( configurationMap ); - m_lnfPath = CalamaresUtils::getString( configurationMap, "lnftool" ); - m_widget->setLnfPath( m_lnfPath ); - if ( m_lnfPath.isEmpty() ) - { - cWarning() << "no lnftool given for plasmalnf module."; - } + m_widget->setLnfPath( m_config->lnfToolPath() ); m_liveUser = CalamaresUtils::getString( configurationMap, "liveuser" ); @@ -186,7 +181,7 @@ void PlasmaLnfViewStep::themeSelected( const QString& id ) { m_themeId = id; - if ( m_lnfPath.isEmpty() ) + if ( m_config->lnfToolPath().isEmpty() ) { cWarning() << "no lnftool given for plasmalnf module."; return; @@ -194,18 +189,18 @@ PlasmaLnfViewStep::themeSelected( const QString& id ) QProcess lnftool; if ( !m_liveUser.isEmpty() ) - lnftool.start( "sudo", { "-E", "-H", "-u", m_liveUser, m_lnfPath, "--resetLayout", "--apply", id } ); + lnftool.start( "sudo", { "-E", "-H", "-u", m_liveUser, m_config->lnfToolPath(), "--resetLayout", "--apply", id } ); else - lnftool.start( m_lnfPath, { "--resetLayout", "--apply", id } ); + lnftool.start( m_config->lnfToolPath(), { "--resetLayout", "--apply", id } ); if ( !lnftool.waitForStarted( 1000 ) ) { - cWarning() << "could not start look-and-feel" << m_lnfPath; + cWarning() << "could not start look-and-feel" << m_config->lnfToolPath(); return; } if ( !lnftool.waitForFinished() ) { - cWarning() << m_lnfPath << "timed out."; + cWarning() << m_config->lnfToolPath() << "timed out."; return; } diff --git a/src/modules/plasmalnf/PlasmaLnfViewStep.h b/src/modules/plasmalnf/PlasmaLnfViewStep.h index f30761ffc..1f97f91b2 100644 --- a/src/modules/plasmalnf/PlasmaLnfViewStep.h +++ b/src/modules/plasmalnf/PlasmaLnfViewStep.h @@ -47,7 +47,6 @@ public slots: private: Config* m_config; PlasmaLnfPage* m_widget; - QString m_lnfPath; // Path to the lnf tool QString m_themeId; // Id of selected theme QString m_liveUser; // Name of the live user (for OEM mode) };