diff --git a/src/modules/plasmalnf/CMakeLists.txt b/src/modules/plasmalnf/CMakeLists.txt index 727c9e7df..4eeb0f7af 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 5.29 REQUIRED CoreAddons Plasma Service ) +find_package( KF5 5.29 REQUIRED CoreAddons Plasma Service Package ) calamares_add_plugin( plasmalnf TYPE viewmodule @@ -13,6 +13,7 @@ calamares_add_plugin( plasmalnf page_plasmalnf.ui LINK_PRIVATE_LIBRARIES calamaresui + KF5::Package KF5::Plasma KF5::Service SHARED_LIB diff --git a/src/modules/plasmalnf/PlasmaLnfInfo.cpp b/src/modules/plasmalnf/PlasmaLnfInfo.cpp index 420c57919..27655b841 100644 --- a/src/modules/plasmalnf/PlasmaLnfInfo.cpp +++ b/src/modules/plasmalnf/PlasmaLnfInfo.cpp @@ -29,6 +29,8 @@ #include // Future #include // TODO: port to KPluginLoader +#include +#include #include "utils/Logger.h" @@ -36,6 +38,20 @@ namespace Calamares { +QStringList themes_by_package() +{ + QStringList packages; + + QList pkgs = KPackage::PackageLoader::self()->listPackages("Plasma/LookAndFeel"); + + for (const KPluginMetaData &data : pkgs) { + packages << data.pluginId(); + } + + return packages; +} + + QStringList themes_by_service() { KService::List services; @@ -88,7 +104,7 @@ QStringList themes_by_lnftool() QStringList packages; QProcess lnftool; - lnftool.start( "lookandfeeltool", {"--list"} ); + lnftool.start( Calamares::lnftool(), {"--list"} ); if ( lnftool.waitForStarted(1000) && lnftool.waitForFinished( 1000 ) && (lnftool.exitCode() == 0) && (lnftool.exitStatus() == QProcess::NormalExit ) ) { packages = QString::fromLocal8Bit( lnftool.readAllStandardOutput() ).trimmed().split('\n'); @@ -96,4 +112,17 @@ QStringList themes_by_lnftool() return packages; } +QStringList plasma_themes() +{ + QStringList l( themes_by_package() ); + if (l.isEmpty()) + return themes_by_lnftool(); + return l; +} + +QString lnftool() +{ + return "/home/adridg/bin/lookandfeeltool"; +} + } // namespace Calamares diff --git a/src/modules/plasmalnf/PlasmaLnfInfo.h b/src/modules/plasmalnf/PlasmaLnfInfo.h index 1ee2cd2ac..a35f8d1e6 100644 --- a/src/modules/plasmalnf/PlasmaLnfInfo.h +++ b/src/modules/plasmalnf/PlasmaLnfInfo.h @@ -23,11 +23,15 @@ namespace Calamares { +QString lnftool(); + /* Internal */ +QStringList themes_by_package(); QStringList themes_by_service(); QStringList themes_by_kcm(); QStringList themes_by_lnftool(); +QStringList plasma_themes(); } #endif // PLASMALNFINFO_H diff --git a/src/modules/plasmalnf/PlasmaLnfPage.cpp b/src/modules/plasmalnf/PlasmaLnfPage.cpp index eee9534c4..0d09026a2 100644 --- a/src/modules/plasmalnf/PlasmaLnfPage.cpp +++ b/src/modules/plasmalnf/PlasmaLnfPage.cpp @@ -32,6 +32,7 @@ #include #include #include +#include PlasmaLnfPage::PlasmaLnfPage(QWidget *parent) : QWidget( parent ) @@ -45,7 +46,22 @@ PlasmaLnfPage::PlasmaLnfPage(QWidget *parent) ui->generalExplanation->setText( tr( "Please choose a look-and-feel for the KDE Plasma Desktop, below." ) ); ) - Calamares::themes_by_service(); - ui->lnfCombo->addItems( Calamares::themes_by_lnftool() ); + Calamares::themes_by_package(); + ui->lnfCombo->addItems( Calamares::plasma_themes() ); + + QObject::connect(ui->lnfCombo, &QComboBox::activated, this, &PlasmaLnfPage::activated); } +void +PlasmaLnfPage::activated(const QString& name) +{ + cDebug() << "Changed to" << name; + + QProcess lnftool; + lnftool.start( Calamares::lnftool(), {"--apply", name} ); + + if ( lnftool.waitForStarted(1000) && lnftool.waitForFinished( 1000 ) && (lnftool.exitCode() == 0) && (lnftool.exitStatus() == QProcess::NormalExit ) ) + ; // OK + else + cDebug() << "WARNING: could not apply look-and-feel" << name; +} diff --git a/src/modules/plasmalnf/PlasmaLnfPage.h b/src/modules/plasmalnf/PlasmaLnfPage.h index f7a17720a..753911bbb 100644 --- a/src/modules/plasmalnf/PlasmaLnfPage.h +++ b/src/modules/plasmalnf/PlasmaLnfPage.h @@ -33,6 +33,9 @@ class PlasmaLnfPage : public QWidget public: explicit PlasmaLnfPage( QWidget* parent = nullptr ); +public slots: + void activated(const QString& name); + private: Ui::PlasmaLnfPage* ui; };