From 105e06798e974141ed2c9e343a23704e635671b2 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 31 Oct 2017 08:25:57 -0400 Subject: [PATCH 1/3] CMake: look for ECM at top-level, add to search path if found. --- CMakeLists.txt | 10 ++++++++++ src/modules/interactiveterminal/CMakeLists.txt | 3 +-- src/modules/partition/CMakeLists.txt | 3 +-- src/modules/users/CMakeLists.txt | 3 +-- 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index aa0d9016b..fccecb539 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -114,6 +114,16 @@ find_package( Qt5 ${QT_VERSION} CONFIG REQUIRED Core Gui Widgets LinguistTools S find_package( YAMLCPP 0.5.1 REQUIRED ) find_package( PolkitQt5-1 REQUIRED ) +# Find ECM once, and add it to the module search path; Calamares +# modules that need ECM can do +# find_package(ECM ${ECM_VERSION} REQUIRED NO_MODULE), +# no need to mess with the module path after. +set( ECM_VERSION 5.10.0 ) +find_package(ECM ${ECM_VERSION} NO_MODULE) +if( ECM_FOUND ) + set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${CMAKE_MODULE_PATH}) +endif() + option( INSTALL_CONFIG "Install configuration files" ON ) option( WITH_PYTHON "Enable Python modules API (requires Boost.Python)." ON ) option( WITH_PYTHONQT "Enable next generation Python modules API (experimental, requires PythonQt)." OFF ) diff --git a/src/modules/interactiveterminal/CMakeLists.txt b/src/modules/interactiveterminal/CMakeLists.txt index 04c5406ce..d419a22a7 100644 --- a/src/modules/interactiveterminal/CMakeLists.txt +++ b/src/modules/interactiveterminal/CMakeLists.txt @@ -1,5 +1,4 @@ -find_package(ECM 5.10.0 REQUIRED NO_MODULE) -set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${CMAKE_MODULE_PATH}) +find_package(ECM ${ECM_VERSION} REQUIRED NO_MODULE) include(KDEInstallDirs) include(GenerateExportHeader) diff --git a/src/modules/partition/CMakeLists.txt b/src/modules/partition/CMakeLists.txt index a60801531..9c67e6aca 100644 --- a/src/modules/partition/CMakeLists.txt +++ b/src/modules/partition/CMakeLists.txt @@ -1,5 +1,4 @@ -find_package(ECM 5.10.0 REQUIRED NO_MODULE) -set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${CMAKE_MODULE_PATH}) +find_package(ECM ${ECM_VERSION} REQUIRED NO_MODULE) include(KDEInstallDirs) include(GenerateExportHeader) diff --git a/src/modules/users/CMakeLists.txt b/src/modules/users/CMakeLists.txt index 074118d54..ebff9df8c 100644 --- a/src/modules/users/CMakeLists.txt +++ b/src/modules/users/CMakeLists.txt @@ -1,6 +1,5 @@ -find_package(ECM 5.10.0 NO_MODULE) +find_package(ECM ${ECM_VERSION} NO_MODULE) if( ECM_FOUND ) - set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${CMAKE_MODULE_PATH}) include( ECMAddTests ) endif() From 6c873f0b703144267f6236a4096ca4fe56a5c002 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 31 Oct 2017 08:26:23 -0400 Subject: [PATCH 2/3] [plasmalnf] Initial stub module --- src/modules/plasmalnf/CMakeLists.txt | 13 ++++++ src/modules/plasmalnf/PlasmaLnfJob.cpp | 64 ++++++++++++++++++++++++++ src/modules/plasmalnf/PlasmaLnfJob.h | 51 ++++++++++++++++++++ 3 files changed, 128 insertions(+) create mode 100644 src/modules/plasmalnf/CMakeLists.txt create mode 100644 src/modules/plasmalnf/PlasmaLnfJob.cpp create mode 100644 src/modules/plasmalnf/PlasmaLnfJob.h diff --git a/src/modules/plasmalnf/CMakeLists.txt b/src/modules/plasmalnf/CMakeLists.txt new file mode 100644 index 000000000..3a6c0324f --- /dev/null +++ b/src/modules/plasmalnf/CMakeLists.txt @@ -0,0 +1,13 @@ +find_package(ECM ${ECM_VERSION} REQUIRED NO_MODULE) + +find_package( KF5 REQUIRED CoreAddons Service ) + +calamares_add_plugin( plasmalnf + TYPE job + EXPORT_MACRO PLUGINDLLEXPORT_PRO + SOURCES + PlasmaLnfJob.cpp + LINK_PRIVATE_LIBRARIES + calamares + SHARED_LIB +) diff --git a/src/modules/plasmalnf/PlasmaLnfJob.cpp b/src/modules/plasmalnf/PlasmaLnfJob.cpp new file mode 100644 index 000000000..15b4e39ce --- /dev/null +++ b/src/modules/plasmalnf/PlasmaLnfJob.cpp @@ -0,0 +1,64 @@ +/* === This file is part of Calamares - === + * + * Copyright 2017, Adriaan de Groot + * + * Calamares is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Calamares is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Calamares. If not, see . + */ + +#include "PlasmaLnfJob.h" + +#include +#include +#include + +#include "CalamaresVersion.h" +#include "JobQueue.h" +#include "GlobalStorage.h" + +#include "utils/Logger.h" + +PlasmaLnfJob::PlasmaLnfJob( QObject* parent ) + : Calamares::CppJob( parent ) +{ +} + + +PlasmaLnfJob::~PlasmaLnfJob() +{ +} + + +QString +PlasmaLnfJob::prettyName() const +{ + return tr( "Plasma Look-and-Feel Job" ); +} + + +Calamares::JobResult +PlasmaLnfJob::exec() +{ + cDebug() << "Plasma Look-and-Feel Job"; + + 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 new file mode 100644 index 000000000..db56d8be9 --- /dev/null +++ b/src/modules/plasmalnf/PlasmaLnfJob.h @@ -0,0 +1,51 @@ +/* === This file is part of Calamares - === + * + * Copyright 2017, Adriaan de Groot + * + * Calamares is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Calamares is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Calamares. If not, see . + */ + +#ifndef PLASMALNFJOB_H +#define PLASMALNFJOB_H + +#include +#include + +#include + +#include + +#include + +class PLUGINDLLEXPORT PlasmaLnfJob : public Calamares::CppJob +{ + Q_OBJECT + +public: + explicit PlasmaLnfJob( QObject* parent = nullptr ); + virtual ~PlasmaLnfJob() override; + + QString prettyName() const override; + + Calamares::JobResult exec() override; + + void setConfigurationMap( const QVariantMap& configurationMap ) override; + +private: + QVariantMap m_configurationMap; +}; + +CALAMARES_PLUGIN_FACTORY_DECLARATION( PlasmaLnfJobFactory ) + +#endif // PLASMALNFJOB_H From 41e8fdd362a7fe888afac203d4b1204e991d86b8 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 31 Oct 2017 09:49:16 -0400 Subject: [PATCH 3/3] [plasmalnf] Search for LNF themes like the KCM does --- src/modules/plasmalnf/CMakeLists.txt | 4 +- src/modules/plasmalnf/PlasmaLnfJob.cpp | 52 +++++++++++++++++++++++++- 2 files changed, 54 insertions(+), 2 deletions(-) diff --git a/src/modules/plasmalnf/CMakeLists.txt b/src/modules/plasmalnf/CMakeLists.txt index 3a6c0324f..b78aac6b8 100644 --- a/src/modules/plasmalnf/CMakeLists.txt +++ b/src/modules/plasmalnf/CMakeLists.txt @@ -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 ) diff --git a/src/modules/plasmalnf/PlasmaLnfJob.cpp b/src/modules/plasmalnf/PlasmaLnfJob.cpp index 15b4e39ce..0aa7314cf 100644 --- a/src/modules/plasmalnf/PlasmaLnfJob.cpp +++ b/src/modules/plasmalnf/PlasmaLnfJob.cpp @@ -18,10 +18,18 @@ #include "PlasmaLnfJob.h" -#include #include +#include +#include +#include #include +#include +#include +#include // Future + +#include // 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 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(); }