[plasmalnf] Get available LNF
- Implement various ways of getting the LNF; the process-based one uses a recent CLI-tool from the Plasma developers. - Fill the UI with (meaningless) LNF package IDs.
This commit is contained in:
parent
98d758b4be
commit
8c65ee5481
@ -8,9 +8,12 @@ calamares_add_plugin( plasmalnf
|
||||
SOURCES
|
||||
PlasmaLnfViewStep.cpp
|
||||
PlasmaLnfPage.cpp
|
||||
PlasmaLnfInfo.cpp
|
||||
UI
|
||||
page_plasmalnf.ui
|
||||
LINK_PRIVATE_LIBRARIES
|
||||
calamaresui
|
||||
KF5::Plasma
|
||||
KF5::Service
|
||||
SHARED_LIB
|
||||
)
|
||||
|
99
src/modules/plasmalnf/PlasmaLnfInfo.cpp
Normal file
99
src/modules/plasmalnf/PlasmaLnfInfo.cpp
Normal file
@ -0,0 +1,99 @@
|
||||
/* === This file is part of Calamares - <http://github.com/calamares> ===
|
||||
*
|
||||
* Copyright 2017, Adriaan de Groot <groot@kde.org>
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "PlasmaLnfInfo.h"
|
||||
|
||||
#include <QDateTime>
|
||||
#include <QDir>
|
||||
#include <QProcess>
|
||||
#include <QStandardPaths>
|
||||
#include <QThread>
|
||||
|
||||
#include <KService>
|
||||
#include <KServiceTypeTrader>
|
||||
#include <KPluginLoader> // Future
|
||||
|
||||
#include <Plasma/PluginLoader> // TODO: port to KPluginLoader
|
||||
|
||||
#include "utils/Logger.h"
|
||||
|
||||
|
||||
namespace Calamares
|
||||
{
|
||||
|
||||
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<Plasma::Package> 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( "lookandfeeltool", {"--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;
|
||||
}
|
||||
|
||||
} // namespace Calamares
|
33
src/modules/plasmalnf/PlasmaLnfInfo.h
Normal file
33
src/modules/plasmalnf/PlasmaLnfInfo.h
Normal file
@ -0,0 +1,33 @@
|
||||
/* === This file is part of Calamares - <http://github.com/calamares> ===
|
||||
*
|
||||
* Copyright 2017, Adriaan de Groot <groot@kde.org>
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef PLASMALNFINFO_H
|
||||
#define PLASMALNFINFO_H
|
||||
|
||||
#include <QStringList>
|
||||
|
||||
namespace Calamares
|
||||
{
|
||||
|
||||
QStringList themes_by_service();
|
||||
QStringList themes_by_kcm();
|
||||
QStringList themes_by_lnftool();
|
||||
|
||||
}
|
||||
|
||||
#endif // PLASMALNFINFO_H
|
@ -17,6 +17,7 @@
|
||||
*/
|
||||
|
||||
#include "PlasmaLnfPage.h"
|
||||
#include "PlasmaLnfInfo.h"
|
||||
|
||||
#include "ui_page_plasmalnf.h"
|
||||
|
||||
@ -43,5 +44,8 @@ PlasmaLnfPage::PlasmaLnfPage(QWidget *parent)
|
||||
ui->retranslateUi( this );
|
||||
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() );
|
||||
}
|
||||
|
||||
|
@ -13,7 +13,7 @@
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout" stretch="0,0">
|
||||
<layout class="QVBoxLayout" name="verticalLayout" stretch="0,0,0">
|
||||
<item>
|
||||
<widget class="QLabel" name="generalExplanation">
|
||||
<property name="styleSheet">
|
||||
@ -28,6 +28,9 @@ margin-left: 2em;</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="lnfCombo"/>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
|
Loading…
Reference in New Issue
Block a user