From 62623a23760a57e268c039a91b900c480caeb9ff Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Sun, 3 Dec 2017 09:26:59 -0500 Subject: [PATCH] [plasmalnf] Make an actual job of setting the theme - Job doesn't actually run lookandfeeltool in the target system yet. --- src/modules/plasmalnf/CMakeLists.txt | 1 + src/modules/plasmalnf/PlasmaLnfJob.cpp | 53 +++------------------ src/modules/plasmalnf/PlasmaLnfJob.h | 18 +++---- src/modules/plasmalnf/PlasmaLnfPage.cpp | 3 ++ src/modules/plasmalnf/PlasmaLnfPage.h | 3 ++ src/modules/plasmalnf/PlasmaLnfViewStep.cpp | 11 +++++ src/modules/plasmalnf/PlasmaLnfViewStep.h | 4 ++ 7 files changed, 35 insertions(+), 58 deletions(-) diff --git a/src/modules/plasmalnf/CMakeLists.txt b/src/modules/plasmalnf/CMakeLists.txt index 4eeb0f7af..9b3ccf716 100644 --- a/src/modules/plasmalnf/CMakeLists.txt +++ b/src/modules/plasmalnf/CMakeLists.txt @@ -8,6 +8,7 @@ calamares_add_plugin( plasmalnf SOURCES PlasmaLnfViewStep.cpp PlasmaLnfPage.cpp + PlasmaLnfJob.cpp PlasmaLnfInfo.cpp UI page_plasmalnf.ui diff --git a/src/modules/plasmalnf/PlasmaLnfJob.cpp b/src/modules/plasmalnf/PlasmaLnfJob.cpp index 0aa7314cf..696995abe 100644 --- a/src/modules/plasmalnf/PlasmaLnfJob.cpp +++ b/src/modules/plasmalnf/PlasmaLnfJob.cpp @@ -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 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(); ) diff --git a/src/modules/plasmalnf/PlasmaLnfJob.h b/src/modules/plasmalnf/PlasmaLnfJob.h index db56d8be9..a9fa29282 100644 --- a/src/modules/plasmalnf/PlasmaLnfJob.h +++ b/src/modules/plasmalnf/PlasmaLnfJob.h @@ -22,30 +22,24 @@ #include #include -#include +#include -#include - -#include - -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 diff --git a/src/modules/plasmalnf/PlasmaLnfPage.cpp b/src/modules/plasmalnf/PlasmaLnfPage.cpp index 0d09026a2..4989bbbcd 100644 --- a/src/modules/plasmalnf/PlasmaLnfPage.cpp +++ b/src/modules/plasmalnf/PlasmaLnfPage.cpp @@ -64,4 +64,7 @@ PlasmaLnfPage::activated(const QString& name) ; // OK else cDebug() << "WARNING: could not apply look-and-feel" << name; + + + emit plasmaThemeSelected( name ); } diff --git a/src/modules/plasmalnf/PlasmaLnfPage.h b/src/modules/plasmalnf/PlasmaLnfPage.h index 753911bbb..ceed37044 100644 --- a/src/modules/plasmalnf/PlasmaLnfPage.h +++ b/src/modules/plasmalnf/PlasmaLnfPage.h @@ -36,6 +36,9 @@ public: public slots: void activated(const QString& name); +signals: + void plasmaThemeSelected( const QString &id ); + private: Ui::PlasmaLnfPage* ui; }; diff --git a/src/modules/plasmalnf/PlasmaLnfViewStep.cpp b/src/modules/plasmalnf/PlasmaLnfViewStep.cpp index eac93a6e1..0b824fc46 100644 --- a/src/modules/plasmalnf/PlasmaLnfViewStep.cpp +++ b/src/modules/plasmalnf/PlasmaLnfViewStep.cpp @@ -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; +} diff --git a/src/modules/plasmalnf/PlasmaLnfViewStep.h b/src/modules/plasmalnf/PlasmaLnfViewStep.h index 99a48b79c..cdc447b7e 100644 --- a/src/modules/plasmalnf/PlasmaLnfViewStep.h +++ b/src/modules/plasmalnf/PlasmaLnfViewStep.h @@ -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 )