From fe8ff3ab05d8fd9ae3c85a931d7313514f9d55c7 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Sun, 3 Dec 2017 15:34:06 -0500 Subject: [PATCH] [plasmalnf] Simplify code, remove redundant implementations --- src/modules/plasmalnf/CMakeLists.txt | 3 +- src/modules/plasmalnf/PlasmaLnfInfo.cpp | 82 ------------------------- src/modules/plasmalnf/PlasmaLnfInfo.h | 8 --- src/modules/plasmalnf/PlasmaLnfPage.cpp | 20 +++++- 4 files changed, 19 insertions(+), 94 deletions(-) diff --git a/src/modules/plasmalnf/CMakeLists.txt b/src/modules/plasmalnf/CMakeLists.txt index 9b3ccf716..1bbc555c8 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 Package ) +find_package( KF5 5.29 REQUIRED CoreAddons Plasma Package ) calamares_add_plugin( plasmalnf TYPE viewmodule @@ -16,6 +16,5 @@ calamares_add_plugin( plasmalnf calamaresui KF5::Package KF5::Plasma - KF5::Service SHARED_LIB ) diff --git a/src/modules/plasmalnf/PlasmaLnfInfo.cpp b/src/modules/plasmalnf/PlasmaLnfInfo.cpp index 6e9249825..1112ee18a 100644 --- a/src/modules/plasmalnf/PlasmaLnfInfo.cpp +++ b/src/modules/plasmalnf/PlasmaLnfInfo.cpp @@ -38,88 +38,6 @@ 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; - KServiceTypeTrader* trader = KServiceTypeTrader::self(); - - cDebug() << "Plasma themes by service:"; - QStringList packages; - services = trader->query("Plasma/Theme"); - int c = 0; - for ( const auto s : services ) - { - cDebug() << " .. Plasma theme" << s->name(); - packages << s->name(); - c++; - } - - return packages; -} - -QStringList themes_by_kcm() -{ - QString component; - QList packages; - QStringList paths; - QStringList packageNames; - 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); - } - - cDebug() << "Plasma themes by kcm:"; - 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; - packageNames << pkg.metadata().pluginName(); - cDebug() << " .. Plasma theme" << pkg.metadata().pluginName(); - } - } - - return packageNames; -} - -QStringList themes_by_lnftool() -{ - QStringList packages; - - QProcess lnftool; - 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'); - } - return packages; -} - -QStringList plasma_themes() -{ - QStringList l( themes_by_package() ); - if (l.isEmpty()) - return themes_by_lnftool(); - return l; -} - static QString *p_lnfPath = nullptr; QString lnftool() diff --git a/src/modules/plasmalnf/PlasmaLnfInfo.h b/src/modules/plasmalnf/PlasmaLnfInfo.h index 27adc224c..f1ed43b72 100644 --- a/src/modules/plasmalnf/PlasmaLnfInfo.h +++ b/src/modules/plasmalnf/PlasmaLnfInfo.h @@ -26,14 +26,6 @@ namespace Calamares { QString lnftool(); void set_lnftool( const QString& ); - - /* 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 632b9f13a..5a94ac789 100644 --- a/src/modules/plasmalnf/PlasmaLnfPage.cpp +++ b/src/modules/plasmalnf/PlasmaLnfPage.cpp @@ -29,11 +29,28 @@ #include "utils/Retranslator.h" #include "ViewManager.h" +#include +#include + #include #include #include #include +static QStringList plasma_themes() +{ + QStringList packages; + + QList pkgs = KPackage::PackageLoader::self()->listPackages("Plasma/LookAndFeel"); + + for (const KPluginMetaData &data : pkgs) { + packages << data.pluginId(); + } + + return packages; +} + + PlasmaLnfPage::PlasmaLnfPage(QWidget *parent) : QWidget( parent ) , ui( new Ui::PlasmaLnfPage ) @@ -46,8 +63,7 @@ PlasmaLnfPage::PlasmaLnfPage(QWidget *parent) ui->generalExplanation->setText( tr( "Please choose a look-and-feel for the KDE Plasma Desktop, below." ) ); ) - Calamares::themes_by_package(); - ui->lnfCombo->addItems( Calamares::plasma_themes() ); + ui->lnfCombo->addItems( plasma_themes() ); QObject::connect(ui->lnfCombo, &QComboBox::activated, this, &PlasmaLnfPage::activated); }